Question: this is the code I've been trying to debug. after the code prints out the two numbers in the 4th step; print( Odd numbers between

this is the code I've been trying to debug. after the code prints out the two numbers in the 4th step; print(" Odd numbers between ", a,"and ", b," : ") nothign happens. the calculation and the following step never shows..

would you take a look and give me some tips on how to fix this?

python program not using math import

each step must be done in a loop

1.program shows all even numbers 2-100 and sum

2.then the square numbers between 1 and 100 (inclusive) and their sum.

3.display powers of 2 going from 1-256 (16^2=256. =last number to be shown is 16)

4.prompt user to input 2 numbers and shows all odd numbers between a - b (inclusive) and their sum

5.has user input another number and display the sum of the odd digits of number. displays the sum of all odd digits of an input. (ex, user types in 25561 sum displayed would be 5+5+1=11)

i = 2 sum = 0 print("Even numbers between 2 and 200 : ") while(i <= 200): if(i % 2 == 0): print(i, end = ' ') sum = sum + i i = i + 1 print(" Sum of even numbers between 2 and 200 :", sum)

print(" Square of number between 1 to 100: ") i = 1 sum = 0 while(i <= 100): sum = sum + (i * i) print((i*i), end =' ') i = i + 1 print(" Sum of square of number from 1 to 100 : ", sum) i = 1 print(" Powers of 2 from 1 to 256 :") while(i <= 16): print(" ", i ** 2) i = i + 1

a = int(input("Enter the lower limit :")) b = int(input("Enter the upper limit :")) sum = 0 print(" Odd numbers between ", a,"and ", b," : ") x = a while(a <= b): if(a % 2 == 1): print(a, end = ' ') sum = sum + a a + 1 print(" Sum of odd numbers between ", x, "and", b, ":",sum)

num = int(input("Enter a number :")) sum = 0 i = 1 while(num != 0): a = num % 10 if(i % 2 == 1): sum = sum + x num = num // 10 i = i + 1 print(" Sum of digits of odd places :", sum)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!