Site will go through some rearranging. Make it less like the The Coli. If you have ideas, please share in The Barber Shop.
Inputs and Outputs of a FunctionSpoiler (hover to show)def format_name_1(fName, lName): print(fName.title()) print(lName.title())def format_name_2(fName, lName): first_name = fName.title() last_name = lName.title() print(first_name) print(last_name)def format_name_3(fName, lName): return f"{fName.title()} {lName.title()}"formatted_name = format_name_3("mary", "MACkEY")print(formatted_name)ChallengeSpoiler (hover to show)#Challengedef Is_Year_Leap_Year(year): isLeapYear = False if year % 4 == 0: if year % 100 == 0: if year % 400 == 0: isLeapYear = True else: isLeapYear = False else: isLeapYear = True else: isLeapYear = False return isLeapYeardef days_in_month(year, month): month_days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] isLeapYear = Is_Year_Leap_Year(year) if month == 2 and isLeapYear: return 29 else: return month_days[month - 1]year = int(input("Enter a year: "))month = int(input("Enter a month: "))days = days_in_month(year, month)print(f"There are {days} days in year {year}, month {month}.")Example of a docstringSpoiler (hover to show)def test(): """ This function is documented. But does nothing. """ print("I'm just a test.")ProjectSpoiler (hover to show)#Projectdef add(n1, n2): return n1 + n2def subtract(n1, n2): return n1 - n2def multiply(n1, n2): return n1 * n2def divide(n1, n2): return n1 / n2operations = { "+": add, "-": subtract, "*": multiply, "/": divide}num1 = int(input("What's the first number? "))num2 = int(input("What's the second number? "))for op in operations: print(op)chosen_op = input("Choose one of the operations above: ")function = operations[chosen_op]result = function(num1, num2)print(f"The result is: {result}.")#Challengedef calc_program(): num1 = int(input("What's the first number? ")) num2 = int(input("What's the second number? ")) for op in operations: print(op) chosen_op = input("Choose one of the operations above: ") function = operations[chosen_op] result = function(num1, num2) print(f"{num1} {chosen_op} {num2} = {result}.") doItAgain = input("Type 'y' to continue calculating with 16 or type 'n' to exit. :") while doItAgain == 'y': chosen_op = input("Choose an operation: ") num1 = result num2 = int(input("What's the next number? ")) function = operations[chosen_op] result = function(num1, num2) print(f"{num1} {chosen_op} {num2} = {result}.")
def Is_Year_Leap_Year(year): if year % 4 == 0 and year % 100 == 0 and year % 400 == 0: return True elif year % 4 == 0 and year % 100 == 0: return True return False