human years to dog years - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Homework (https://python-forum.io/forum-9.html) +--- Thread: human years to dog years (/thread-3238.html) |
human years to dog years - jhall710 - May-07-2017 This makes no sense why python will not do a simple multiplication instead of duplicating 7 times. Need to be able to input a number in human years and then have the code print both human years and dog years. code posted below. human_years = input('How old are you? ') dog_years = human_years * 7 # use the variable name dog_years so that the print statements below will print out the correct values. print("You are", human_years, "in human years") print("You are", dog_years, "in dog years") RE: human years to dog years - ichabod801 - May-07-2017 The input function returns a string (if you are using 3.0 or later). Multiplying strings repeats them. If you want integer multiplication, you need to convert the string with int(). RE: human years to dog years - Larz60+ - May-08-2017 Who determined a dog year is 7 times a human year. Don't they go through the same number of winters and summers? Perhaps their concept of a year is the same as ours, but they just age faster RE: human years to dog years - ichabod801 - May-08-2017 It depends on who you talk to. RE: human years to dog years - sparkz_alot - May-08-2017 Now calculate what that would be in sea turtle years. RE: human years to dog years - ichabod801 - May-08-2017 What do you mean? African or European sea turtle? RE: human years to dog years - nilamo - May-08-2017 I don't know that! *aaaarrrggghhh* RE: human years to dog years - Larz60+ - May-08-2017 I asked my dog, he had nothing to say! |