diff --git a/challenges/week_1/Readme.md b/challenges/week_1/Readme.md index 430ab42..3846a5d 100644 --- a/challenges/week_1/Readme.md +++ b/challenges/week_1/Readme.md @@ -29,3 +29,11 @@ Run the [Checker](checker.py) file to evaluate your code. If all tests pass, you - `'fare'` *Failure to which all your tests will fail.* 3. The **Checker** file should **never** be **altered** at any cost. + + +Pseudo-code for the project + +Step 1: obtain the date today using the datetime module +step 2: obtain the day in the form of "Mon", "Tue" etc +step 3: make a list of busfares with an accompanying day +step 4: check if the day today is in the list of bus fares and then print the dates and fare. diff --git a/challenges/week_1/bus_fare_challenge.py b/challenges/week_1/bus_fare_challenge.py index 0b90aa0..bf38a63 100644 --- a/challenges/week_1/bus_fare_challenge.py +++ b/challenges/week_1/bus_fare_challenge.py @@ -1 +1,26 @@ -# WRITE YOUR CODE SOLUTION HERE +from datetime import date +#initialize the date today +date = date.today() + +#obtain the day in the form "Mon", "Tue" etc. +day = date.strftime("%a") + +bus_fare = { + "Mon":100, + "Tue":100, + "Wen":100, + "Thur":100, + "Fri":100, + "Sat":60, + "Sun":80 +} +#initialize the fare variable +fare = None +#check if the day is in the bus_fare dictionary +if day in bus_fare: + print(date) + print(day) + fare = bus_fare[day] + print(fare) + + diff --git a/challenges/week_2/personal_converter.py b/challenges/week_2/personal_converter.py new file mode 100644 index 0000000..772e0a7 --- /dev/null +++ b/challenges/week_2/personal_converter.py @@ -0,0 +1,83 @@ +""" +Pseudo code for the challenge +1. create a converter function +2. Obtain the name of the user using the input function +3. print the name of the user with the choices to choose from +4. within the converter function specify the individual converter functions. +5. from the choice selected by user, run the corresponding converter function +6. Return the results to the user. +""" + +def converter(): + # ask the name input from the user + name = str(input("Input your name:")) + # print the name of the user and the hello message + print("Hello {}, welcome to your personal converter.".format(name)) + print("Please choose which conversion you would like to perform:") + print("1 - convert cm to inches\n2 - convert percent to letter grade\n3 - convert cups to ml\n4 - convert grams to ounces\n5 - convert fahrenheit to celsius\n") + # ask the user to choose the number for the choice + choice = int(input("Choice:")) + + # the function converting cm to inches + def cm_to_inch(): + num = int(input("Value in cm to convert: ")) + result = "{}cm = {}inches".format(num, num*0.39370) + print(result) + # function getting the percent and giving the respective letter grade + + def percent_to_letter_grade(): + num = float(input("Percent to convert to letter grade: ")) + num1 = int(num) + if num1 in range(80, 101, 1): + result = "A" + if num1 in range(70, 80, 1): + result = "B" + if num1 in range(60, 70, 1): + result = "C" + if num1 in range(50, 60, 1): + result = "D" + if num1 in range(20, 50, 1): + result = "E" + if num1 in range(0, 40, 1): + result = "F" + else: + print("Num not in required range") + result = "{}% = {}".format(num, result) + print(result) + + # function changing cups to ml + def cups_to_ml(): + num = int(input("Enter the number of cups to convert: ")) + result = "{} cups = {} ml".format(num, num*250) + print(result) + + # functin changing grams to ounces + def grams_to_ounces(): + num = float( + input("Enter the number of grams to convert to ounces: ")) + result = "{} grams = {} ounces".format(num, num*0.0352) + print(result) + + # function changing farenheit to celcius + def farenheit_to_celcius(): + num = float(input("Value to convert Farenheit to Celcius: ")) + result = "{} Farenheit = {}\u00b0 C".format( + num, round((num-32)*5/9), 2) + print(result) + if choice == 1: + cm_to_inch() + elif choice == 2: + percent_to_letter_grade() + elif choice == 3: + cups_to_ml() + elif choice == 4: + grams_to_ounces() + elif choice == 5: + farenheit_to_celcius() + else: + print("The choice is not valid.") + return "Goodbye {}".format(name) + + +if __name__ == "__main__": + converter()