Write a program that randomly generates two integers

Assignment Help Python Programming
Reference no: EM132356398

Exercise: Math quiz

Topics : While loops for program control, while loops for input validation, running total, selection statements

1. Write a program that randomly generates two integers between 1 and 10. It should then prompt the user to select +, -, /, or *. The program should then prompt the user for the answer to the math problem involving the two random integers and the selected operation. The program then tells the user whether or not they are correct.

2. Add an input validation loop that ensures the user can only enter +, -, /, or *

3. Add a program control loop that allows the user to continue answering questions until they quit.

4. Add a running total that prints out how many they get correct and how many the get incorrect after they quit the program.

Sample runs:

Hi and welcome to the math quiz!

Do you want to answer a question (Y/N)? Y

Do you want to +, -, /, or * (select one): *

The problem is: 5 * 8

Enter the answer: 40

You are correct!

Do you want to answer another question (Y/N)? Y

Do you want to +, -, /, or * (select one): @

That is not a valid selection. Do you want to +, -, /, or * (select one): /

The problem is: 2 / 10

Enter the answer: .2

You are correct!

Do you want to answer another question (Y/N)? Y

Do you want to +, -, /, or * (select one)? &

That is not a valid selection. Do you want to +, -, /, or * (select one): =

That is not a valid selection. Do you want to +, -, /, or * (select one): +

The problem is: 9 + 1

Enter the answer: 11

Incorrect.

Do you want to answer another question (Y/N)? N

Reference no: EM132356398

Questions Cloud

How has this course changed your perspective : What were some of the more interesting assignments to you? How has this course changed your perspective? Where might you use modeling in the future?
Emerging threats and countermeasures-cyber attacks : ITS 832-ITS 834-IT in Global economy-Policypractice, Emerging threats and countermeasures - Cyber attacks. how you participate in business operations
Describe the offensive or defensive competitive strategy : To combat competition from cheaper rivals in the natural food space, Whole Foods organic supermarkets recently launched "365 by Whole Foods," a sister chain of.
Determine and print the height of the tallest employee : Write Python code and flowchart for the following program. Ask for the number employees on Khan company payroll. determine and print the height of the tallest
Write a program that randomly generates two integers : Write a program that randomly generates two integers between 1 and 10. Add an input validation loop that ensures the user can only enter.
Managing and assessing information security policy : Using a graphics program, design several security awareness posters on the following themes: updating antivirus signatures, protecting sensitive information,
Comment on article - iacom improves performance as cbs : Write a comment with the two article on the Discussion. Article # 1 Fiserv to Acquire First Data in $22 Billion All-Stock Deal
What evidence supports providing care in a particular way : NSG2NMR Nursing And Midwifery Research Assignment, La Trobe University, Australia. What evidence supports providing care in a particular way
Show the classification of organic compounds : Show the Classification of organic compounds.

Reviews

Write a Review

Python Programming Questions & Answers

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd