Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Modify the program below and write a PYTHON3 program that asks the user for a number n and gives him the possibility to choose between

Modify the program below and write a PYTHON3 program that asks the user for a number n and gives him the possibility to choose between computing the sum and computing the product.image text in transcribed

print() # Taking value from user using input function # And we know that input() function takes value as string so, we typecast it to int using int() function int(input("Enter the value of n: ")) # Intializing totalSum variable as 0 # Intializing product variable as 1 totalSum = 0 product = 1 # To calcualte sum and product we use for loop # range(n) will take value of i variable from 0 to n-1 # So, at calculating sum and product we use (i+1) for i in range(n): totalSum = totalSum+i+1 product # Displaying the value of sum and product using print() function print("The sum of the first n values is :", totalSum) print("The product of the first n values is: ", product) product*(i+1) %3D print()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introductory Relational Database Design For Business With Microsoft Access

Authors: Jonathan Eckstein, Bonnie R. Schultz

1st Edition

1119329418, 978-1119329411

More Books

Students also viewed these Databases questions