Skip to content

Instantly share code, notes, and snippets.

@klamfa
Last active October 28, 2019 06:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save klamfa/c4d7cd91f55a5bc97be41aebe05a63ad to your computer and use it in GitHub Desktop.
Save klamfa/c4d7cd91f55a5bc97be41aebe05a63ad to your computer and use it in GitHub Desktop.
Homework 2
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!")
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!")
sentence = str.lower ("HoW vErY NiCE iS ThiS sEntEnCe!")
print (sentence)
@isrdoc
Copy link

isrdoc commented Oct 28, 2019

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.

@klamfa
Copy link
Author

klamfa commented Oct 28, 2019

Fixed it, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment