I have 3 different small programs that I have no idea how to display them, I've done the math and stuff, I don't really know what else to say, other than I need desperate help because I don't have anyone in my life that's experienced in this subject and that can help me.
- this one uses a function to determine if any year is a leap year. Make your function return a boolean value. (Leap years are divisible by 4 except if they occur at the beginning of a new century that is not divisible by 400. 1900 was not a leap year; 2000 was.)
- a program that accepts two points on a line and returns the values for m and b in the equation y = mx + b. (m = (y1 - y2) / (x1 - x2) and b = y1 - mx1)
- a program that uses the Euclidean algorithm in a subprogram to find the greatest common factor of two numbers. Example: The GCF of 45 and 55 is 5, from the sequence: 55, 45, 10, 5, 0 . Return the GCF
coding for 1.
def isLeapYear(year):
if year % 4 == 0:
if year % 100 == 0:
if year % 400 == 0:
return True
else:
return False
else:
return True
else:
return False
coding for 2.
rise = y2-y1
run = x2-x1
m = rise/run
b = y2/(m*x2)
return print("m = " + str(m) + " and b = " + str(b))
coding for 3.
def gcf(n1,n2):
remainder = None
while remainder != 0:
remainder = n1 % n2
n1 = n2
n2 = remainder
return n1
EDIT: sorry im bad at explaining things, like for example, i would want the leapyear one to function like; "Enter your leap year!" (stores function) sorry, but (leapyeartheyentered) is not a leap year! (or) (leapyear they entered) is a leap year!
yes someone phrased it because i'm bad at english too i suppose- i want to print the results of the coding