DMV_sums6.py - C:/Users/shell/OneDrive/Desktop/DMV_sums6.py (3.8.2) File Edit Format Run Options Window Help #!/usr/bin/env python3 # Shelly Voelker \t # COP2002.OM2 # March 13, 2020 # Sums # This program uses input from the user to calculate the sum of all odd or even # display a welcome message print ("Sums of Odd and Even Numbers") print () #user input choice='y' #while loop for repeating the exercise while (choice=='y'): #prompt user to enter a number num=int (input ("Please enter a number between 1 and 50:")) #while loop while (num50) : #prompt user to enter a number between 1 and 50 num=int (input ("Please try again. Your number must be between 1 and 50: ") #if the number is even if (num$2==0) #display the message print ("\nYour number is an even number.") #initialize the value of sum sum=0 #calculation of sum of even numbers for i in range (2, num+1,2) : sum+=i #displaying the sum of even numbers print ("The sum of even numbers ranging from 2 to ,num, is:", sum) else: print ("\nYour number is an odd number.") sum=0 #calculation of sum of odd numbers for i in range (1, num+1,2): sum+=i #displaying the sum of odd numbers print ("The sum of the odd numbers ranging from 1 to hum, " is:", sum) choice=input ("\nDo you want to try again? (y/n) ") Ln: 41 Col: 4
DMV_sums6.py - C:/Users/shell/OneDrive/Desktop/DMV_sums6.py (3.8.2) File Edit Format Run Options Window Help #!/usr/bin/env python3 # Shelly Voelker \t # COP2002.OM2 # March 13, 2020 # Sums # This program uses input from the user to calculate the sum of all odd or even # display a welcome message print ("Sums of Odd and Even Numbers") print () #user input choice='y' #while loop for repeating the exercise while (choice=='y'): #prompt user to enter a number num=int (input ("Please enter a number between 1 and 50:")) #while loop while (num50) : #prompt user to enter a number between 1 and 50 num=int (input ("Please try again. Your number must be between 1 and 50: ") #if the number is even if (num$2==0) #display the message print ("\nYour number is an even number.") #initialize the value of sum sum=0 #calculation of sum of even numbers for i in range (2, num+1,2) : sum+=i #displaying the sum of even numbers print ("The sum of even numbers ranging from 2 to ,num, is:", sum) else: print ("\nYour number is an odd number.") sum=0 #calculation of sum of odd numbers for i in range (1, num+1,2): sum+=i #displaying the sum of odd numbers print ("The sum of the odd numbers ranging from 1 to hum, " is:", sum) choice=input ("\nDo you want to try again? (y/n) ") Ln: 41 Col: 4
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
I keep getting a syntax error ("invalid syntax") when I try to run my
How can I fix this error?
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education