Question: Q 2 ) Study the following Python code, and then answer the given question. sum = 0 for n in 4 , 7 , 1

Q2) Study the following Python code, and then answer the given question.
sum =0
for n in 4,7,10,13,16,19,21,24,27,30 :
sum += number
print The total (:={ sum }'}
1-Modify the program to calculate the sum of odd numbers only, using if statement.
2-Now, modify the above program by replacing the list of numbers with a suitable range() function that produces the same output as the above program.
Run your program and then copy and paste the program source code and the console output in in the Answer_file.
 Q2) Study the following Python code, and then answer the given

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!