[Python] [28] [experimental demo includes exercises to practice recursive function] []

Original title:

There are five people sit together, the fifth person to ask how old? He said that 2 years older than 4 people. Asked individuals age 4, he said, is larger than 3 individuals 2 years of age. Asked a third person, said Congress two years than the second. He asked a second person, the first person to say more than two years older. Finally, ask the first man, he said, he is 10 years old. The fifth person to ask how much?

 

 

My source:

# ! / Usr / bin / Python 
# encoding = UTF-8 
# - * - Coding: UTF-8 - * - 

#   five people sit together, 
# ask how old the fifth individual? He said that 2 years older than 4 people. 
# Ask individuals age 4, he said, is larger than 3 individuals 2 years of age. 
# Ask a third person, said Congress two years than the second. 
# Ask a second person, the first person to say more than two years older. 
# Finally asked the first man, he said, he is 10 years old. 
# Will the fifth person how much? 


DEF Age (NUM):
     IF NUM. 1 == : 
        S = 10
         Print ( " ### " , S)
     the else : 
        S = Age (-NUM. 1) +2
         Print ( " the SSS ",s)
    return s

print(age(5))

 

Output:

 

 

 

The original title given answers:

 

 

 

 


-------- (I am dividing line) --------

reference:

1. RUNOOB.COM:https://www.runoob.com/python/python-exercise-example28.html

 

 

Remarks:

Initial modified: October 4, 2019 14:55:39

Environment: Windows 7 / Python 3.7.2

Guess you like

Origin www.cnblogs.com/kaixin2018/p/11622155.html