Last active
October 28, 2019 06:58
-
-
Save klamfa/c4d7cd91f55a5bc97be41aebe05a63ad to your computer and use it in GitHub Desktop.
Homework 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
do_convert = "yes" | |
print("Welcome to the km to mi converter!") | |
while do_convert == "yes": | |
kilometers = int(input("How many kilometers do you want to convert to miles? ")) | |
miles = kilometers * 0.621371 | |
print (str(kilometers) + " km is " + str(miles) + " mi!") | |
do_convert = input("Would you like to make another conversion? Enter yes or no here: ") | |
if do_convert == "no": | |
print ("Thanks for using this converter!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
count_limit = int(input("Please enter the number between 1 and 100 you want me to count to, here: ")) | |
answer = None | |
if count_limit > 100: | |
print("Number is too big!") | |
else: | |
for number in range (1, count_limit + 1): | |
if number % 3 == 0 and number % 5 == 0: | |
answer = "fizzbuzz" | |
elif number % 3 == 0: | |
answer = "fizz" | |
elif number % 5 == 0: | |
answer = "buzz" | |
else: | |
answer = number | |
print (answer) | |
print ("Now try saying THAT three times fast!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sentence = str.lower ("HoW vErY NiCE iS ThiS sEntEnCe!") | |
print (sentence) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Homework2-1, 1: answer = "yes"
At first glance it was not clear to me what this variable will do. I had to read through the rest of the code to find out. You can increase readability by naming this variable something like "do_conversion" or "make_another_conversion".
Homework2-2, 1: chosen_number = int(input("Please enter the number between 1 and 100 you want me to count to, here: "))
Similarly, "chosen_number" made me think what it will be used for (it was clear though that this value comes from the user input, so that is good). Something like "count_limit" would do the trick for me.