In case of any query do comment. Please rate answer as well. Thanks
Note: Image is half cut so last part of the sentence is not visible. But It seems like it is printing the squares of odd numbers till 12. Please do let me know what is the other part.
Answer: This loop never ends here because num is started with 1 and adding 2 after each iteration and so it will never be 12. It will enter in infinite loop.
You can code as below to print squares of odd number till 12:
num = 1
while num <=12:
print(num**2)
num +=2
python print ("num=", num) 12. (2) The following loop should print the squares of the odd...
In Python! Create the program that print out only odd numbers 1,3,5,7,9 Use either a while loop or a for loop to print only odd numbers 1, 3, 5, 7, 9 *tip: you can use range () function, or a condition with ‘break’ (e.g, while count < 10) In python!: Create a program that print out 12 months of a year and associated numbers (e.g., January 1, February 2…). Two lists should be created, and then loop through the list...
Which of the following pseudocode loops will print the odd integers from 25 to 45. A) num = 25 while num <= 45 print num end while B) num = 25 while num <= 45 print num num = num + 1 end while C) num = 1 while num <= 10 print num num = num + 2 end while B) num = 25 while num <=...
I have this code for python: num = int(input()) if num == 0: print('No change') else: dol = num // 100 num %= 100 Quarters = num // 25 num %= 25 Dimes = num // 10 num %= 10 Nickels = num // 5 num %= 5 Pennies = num if dol > 0: if dol == 1: print('1 Dollar') if Dollars > 1: print(dol,'Dollars') if Quarters > 0: if Quarters == 1: print('1 Quarter') if Quarters > 1:...
python programming Which of the following code will print all odd numbers between 3 and 11, each number separated by a space as shown below 35 7 9 11 for i in range(3, 11, 1): if 1%2 ID: print(i, end = " for i in range(3, 10, 2): print(i, end = for i in range, 11, 2): if 152 == 0: print(i, end = "") for i in range 12, 1): print(i, end = "")
Python programming: Write a while loop that prints a. All squares less than n. For example, if n is 100, print 0 1 4 9 16 25 36 49 64 81. b. All positive numbers that are divisible by 10 and less than n. For example, if n is 100, print 10 20 30 40 50 60 70 80 90 c. All powers of two less than n. For example, if n is 100, print 1 2 4 8 16...
Python Print integer numbers up to 100 (1, 2, 3, …..) using a while loop. Each integer number takes a separate line.
Write a python program that uses a while loop to print numbers 100,98,96... all the way to 0. each number should be printed on a seperate line
python la ab X, X Lab 7 Design and implement a Python program that uses a while loop and selection statements to print the sum of the even numbers and the sum of the odd numbers (all integers) read from the keyboard. The sequence of numbers ends with a negative number: So, all numbers considered for printing the two sums are greater than or equal to 0. The sequence may be empty. Here is a possible interaction. Enter an integer:...
Write a Python program (using a nested loop) to print out the following pattern (there is a space between the numbers next to each other). 1 2 1 3 2 1 4 3 2 1 5 4 3 2 1
Consider the following incomplete code segment, which is intended to print the sum of the digits in num. For example, when num is 12345, the code segment should print 15, which represents the sum 1 + 2 + 3 + 4 + 5. int num = 12345; int sum = 0; /* missing loop header */ { sum += num % 10; num /= 10; } System.out.println(sum); Which of the following should replace /* missing loop header */ so that the...