Home > other >  Python frog climb well
Python frog climb well

Time:09-26

A frog fell into 35 meters deep borehole, it jump up during the day every day 5 meters, 3 meters down again in the evening, and ask for a few days can jump out to?
The programming for how to write

CodePudding user response:

=5 variables a, b=3, 35
c=-
Permanent cycle
Print today is the first * day
Climb to what position, and tell the well, if the well is out of circulation, print today is which day
What position to
Print the first * the end of the day

CodePudding user response:

Novice small white has a code...

CodePudding user response:

 jing=35 
-The up=5
The down=3
Num=1
While jing<0:
Print (' day ', num, end="")
Jing +=up
Print (' up ', jing, end="")
If jing>=0:
Break
Jing +=down
Print (' down ', jing)
If jing>=0:
Break
Num +=1


Day 1 up to 30 down - 33
Day 2 up to 28 down - 31
Day 3 up to 26 down - 29
Day 4 up to 24 down - 27
Day 5 up - 22 down to 25
Day 6 up to 20 down - 23
Day 7 up to 18 down - 21
Day 8 up to 16 down - 19
Day up to 14 down 9-17
Up to 12 down day 10-15
Up to 10 down day 11-13
Day 12 up to eight down to 11
Day 13 up to 6 down - 9
Day 14 up to four down - 7
Day 15 up to 2 down to 5
Day 16 up 0

CodePudding user response:

The
reference 3 floor weixin_45903952 response:
 jing=35 
-The up=5
The down=3
Num=1
While jing<0:
Print (' day ', num, end="")
Jing +=up
Print (' up ', jing, end="")
If jing>=0:
Break
Jing +=down
Print (' down ', jing)
If jing>=0:
Break
Num +=1


Day 1 up to 30 down - 33
Day 2 up to 28 down - 31
Day 3 up to 26 down - 29
Day 4 up to 24 down - 27
Day 5 up - 22 down to 25
Day 6 up to 20 down - 23
Day 7 up to 18 down - 21
Day 8 up to 16 down - 19
Day up to 14 down 9-17
Up to 12 down day 10-15
Up to 10 down day 11-13
Day 12 up to eight down to 11
Day 13 up to 6 down - 9
Day 14 up to four down - 7
Day 15 up to 2 down to 5
Day 16 up 0

Thank you very much
  • Related