In: Computer Science
write a for loop that uses the loop control variable to take on the values 0 through 10. In the body of the loop, multiply the value of the loop control variable by 2 and by 10. Execute the program by clicking the Run button at the bottom of the screen. Is the output the same?
KINDLY GIVE THUMBS UP IF SOLUTION IS HELPFUL TO YOU.
#IF YOU HAVE ANY DOUBT THEN PLEASE LET ME INFORM IN COMMENT BOX.
CODE-
#we will use num as loop control variable
#we will use range function with for loop.
#range function iterates from a given starting number to end
number-1.
#for example range(0,5) will iterate through numbers 0,1,2,3,4.It
will exlude 5.
#Program-
for num in range(0,11):
#print the numbers
print("number is :",num)
#print the number multiply by 2
print("after multiplying the number by 2,the number is
:",num*2)
#print the number multiply by 10
print("after multiplying the number by 10,the number is
:",num*10)
output-