+ 1

What sequence of numbers is printed by the following algorithm if the input value is 1? Can someone help me out a bit?

def CodeWrite (num): while ( num < 100 ): flag = 0 i = 2 while ( i < int (num/2)): flag = 1 i = i+1 If flag == 0: Print (num) num =num + 1 And then: modify the function CodeWrite in the preceding problem so that perfect square values are printed. Its fore a project if anyone could help that would be awesome!

16th Jan 2022, 2:14 AM
Ensar
Ensar - avatar
1 Answer
+ 2
Did you test the code? there are indentation problems and typos in there. After the problems are fixed, the code prints output for number 1 ~ 5 and ignore number 6 ~ 99.
16th Jan 2022, 5:01 AM
Ipang