Question: Q 2 ) Study the following Python code, and then answer the given question. sum = 0 for n in 4 , 7 , 1
Q Study the following Python code, and then answer the given question.
sum
for in :
sum number
print The total : sum
Modify the program to calculate the sum of odd numbers only, using if statement.
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 Answerfile.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
