Flow Control(while loop)

1.find all the 3 digit narcissistic number

 (narcissistic number : the cube of every digit  add together equals as this number itself. for instance: 153 = 1*1*1 + 5*5*5 + 3*3*3)

 

2.calculate the result of 1+2+3+4+....+97+97+99+100

 

3.input a integer number(less than 10) , calculate the factorial of the number.

hint:

in math, the factorial we write as ! , the factorial of 5 is !5,  and !5 = 5*4*3*2*1

 

4.print from 1 to 100, but if any number in this range is the multiple of 7 or it has number 7 inside, then print “clap”
samples:
1 2 3 4 5 6 clap 8 9 10 11 12 13 clap 15 16 clap 18 19 20 clap 22 23 24 25 26 clap clap 29 30 31 32 33 34 clap 36 clap 38.........

 

5.generate a random number from the range of 1 to 100, then guess what this number is
process is like(assume generated 45 and all those blue text are input by user):

Hello , the computer just generated a number which is in the range of 1 to 100...
guess what it is?
15
too small
guess what it is?
80
too big
guess what it is?
50
too big
guess what it is?
40
too small
guess what it is?
44
too small
guess what it is?
45
congratulations, you guessed right!

posted @ 2023-11-27 23:12  派若多克斯  阅读(66)  评论(0)    收藏  举报