logo Hurry, Grab up to 30% discount on the entire course
Order Now logo

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Nagendra Singh ChauhanMathematics
(/5)

576 Answers

Hire Me
expert
Expert MasterManagement
(5/5)

762 Answers

Hire Me
expert
Chris BarrieComputer science
(5/5)

762 Answers

Hire Me
expert
William DewarComputer science
(5/5)

642 Answers

Hire Me
Mathematics
(5/5)

Write a program that interacts with the user in the following way.

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Instructions Write python programs for the following.

1. Write a program to approximate

b

sin(x) = Σ

(-1)k (2k+1)!

x2k+1

k=0

where x,

b are inputs given by the user.

2. Write a program that interacts with the user in the following way.

(a) Prompt the user: "Enter a number: ". Accept a number n from the user.

(b) Print the first 5 multiples of that number (example: if the number is 2, then print "2, 4, 6, 8, 10")

(c) Prompt the user: "Continue (y/n)?". Accept an answer.

(d) If the answer is "y", print the next 5 multiples. Then repeat the prompt in step (c).

(e) If the answer is "n", then prompt: "Change numbers (y/n)?"

(f) If the answer is "y", start again from step (a).

(g) If the answer is "n", then exit the program.

3. The guessing game works as follows. The program generates a random number between 1 and 50. The user now has to guess what the number is. The interaction works as follows.

(a) A random number m is generated.

(b) Prompt the user: "Guess the number: ". Accept an input n from the user.

(c) If the number n is less then half of m, then output the message: "The number is much too small." Otherwise, output the message: "The number is too small." Repeat the prompt in step (b).

(d) If the number n is more than one and a half times of m, then output the message: "The number is way too big." Otherwise, output the message: "The number is too big." Repeat the prompt in step (b).

(e) If n is equal to m, then output: "You guessed correctly! Repeat the game? (y/n)". Accept an input from the user.

(f) If the input is "y", then repeat the game starting from step (a). If the input is "n", then exit the game.

Note: Random numbers can be generated using the following piece of code:

import random

random.randint (1,50) # Generates a random integer between 1 and 50

4. Write iterative Python programs (using while loops) for all problems of Assignment 2.

1

(5/5)
Attachments:

Related Questions

. The fundamental operations of create, read, update, and delete (CRUD) in either Python or Java

CS 340 Milestone One Guidelines and Rubric  Overview: For this assignment, you will implement the fundamental operations of create, read, update,

. Develop a program to emulate a purchase transaction at a retail store. This  program will have two classes, a LineItem class and a Transaction class

Retail Transaction Programming Project  Project Requirements:  Develop a program to emulate a purchase transaction at a retail store. This

. The following program contains five errors. Identify the errors and fix them

7COM1028   Secure Systems Programming   Referral Coursework: Secure

. Accepts the following from a user: Item Name Item Quantity Item Price Allows the user to create a file to store the sales receipt contents

Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip

. The final project will encompass developing a web service using a software stack and implementing an industry-standard interface. Regardless of whether you choose to pursue application development goals as a pure developer or as a software engineer

CS 340 Final Project Guidelines and Rubric  Overview The final project will encompass developing a web service using a software stack and impleme