Python Forum
human years to dog years
Thread Rating:
  • 2 Vote(s) - 4.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
human years to dog years
#1
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")
Reply
#2
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().
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#3
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
Reply
#4
It depends on who you talk to.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#5
Now calculate what that would be in sea turtle years.  Big Grin
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply
#6
What do you mean? African or European sea turtle?
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#7
I don't know that! *aaaarrrggghhh*
Reply
#8
I asked my dog, he had nothing to say!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Calculate AGE in years Kessie1971 17 3,318 Apr-26-2023, 03:36 PM
Last Post: deanhystad
  Tracking leap.py years for gregorian calendar (Exercism org) Drone4four 11 3,661 Oct-14-2022, 03:20 PM
Last Post: betinajessen
  Problem with code to calculate weekday for leap years! Event 2 2,798 Dec-15-2018, 05:13 PM
Last Post: Event
  python age calculator need to find the number of years before they turn 100 not using orangevalley 4 9,848 Mar-26-2018, 04:44 AM
Last Post: PyMan

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020