Overview
Module 3 Assignment 1 features the design of a pseudocode and a Python program that uses iteration to guess a number from 1 to 10. Each lab asks you to write pseudocode that plans the program’s logic before you write the program in Python and to turn in three things: 1) the pseudocode, 2) a screenshot of the output, and 3) the Python program.
Instructions
Write pseudocode for a Python program that uses iteration to guess a number from 1 to 10 that matches the computer’s number. Enter a name, the computer selects a number, users guess a number, and they keep guessing until they correctly guess the computer’s number. Turn in the pseudocode, Python program, and a screenshot of your output.
Requirements for Your M3 Assignment 1 Pseudocode & Python with Iteration
Complete a program in pseudocode and Python that performs the following tasks.
How to Complete Your M3 Assignment 1 Pseudocode & Python with Iteration
This is the code found in the file M3Lab1 student:
# Guess a number from 1 to 10
# By C. Calongne, 01/14/2019
# Pseudocode & Python with Iteration M3Lab1_student.py
# Guess a number from 1 to 10
# Write the statements requested in Steps 1-6 below
#
# See the examples in the provided code
# Use structured programming and indent your code.
# Programmer Name: *****add your name here****
import random
# uses randrange instead of randint for better results in Python
3.7
# randrange stops just before the upper range, use (1, 11) for
1-10
num = random.randrange(1, 11)
# Step 1: Ask the player to enter a name or quit to exit
# Step 2: use a while statement to test when the name is not equal to quit
# Step 3: input enter a number from 1 to 10 for the variable
your_guess
# display the number guessed
print("Your number is", your_guess)
while num != your_guess:
# Step 4: Write an if statement for your_guess is less than
num
print("Your guess is too low.")
your_guess = int(input("Guess another number from 1 to 10: "))
elif your_guess > num:
print("Your guess is too high")
your_guess = int(input("Guess another number from 1 to 10: "))
else:
break
print("The correct number was", num)
# Step 5 display text with your guess and You won, name
print("***************************************************************")
# Step 6 ask the player to enter a name or quit to exit
num = random.randrange(1, 11)
print("Thank you for playing!")
Python code:
import random
#initializing i=0 this will help us to determine if game is played
atleast once
i=0
#While loop begins this loop is responsible for asking name until
user enter quit
while True:
#taking input from user
s=input("Enter a name or enter quit to exit ")
#checking if input is quit and game is not played even once
if(s=="quit" and i==0):
break;
#checking if input is quit and game is atleast played even
once
elif(s=="quit" and i!=0):
print("Thank you for playing!")
break;
#if player enters a name
else:
#declaring and initializing variables
name=s
i=1
#this generates a random number between 1 to 10 and stores it in
num
num=random.randrange(1,11)
#taking guess from user and printing it
your_guess=int(input("enter a number from 1 to 10 "))
print("Your number is", your_guess)
#while loop begins this loop is responsible for checking the
number
while your_guess!=num:
#if guess is too low
if(your_guess<num):
print("Your guess is too low")
your_guess = int(input("Guess another number from 1 to 10:
"))
#if guess is too high
elif(your_guess>num):
print("Your guess is too high")
your_guess = int(input("Guess another number from 1 to 10:
"))
#if guess is correct
else:
break
#printing details
print("The correct number was", num)
print("Your guess was ",num," You won ",name)
Code Screenshots:
Output Screenshot:
Pseudocode:
i=0
while loop until breaked
s=Enter a name or quit
if input is quit and i=0
break while loop
else if input is quit and i not equal to 0
print Thank you for playing
break while loop
else if input is a name
set i=1
num=generate a random number
between 1 to 10
your_guess=Enter a number from 1 to
10
while loop until your_guess not
equal to num
if input is less
than num
print too low
your_guess= another input
else if input is
too high
print too high
your_guess= another input
else if input is
equal to the number
break this while loop
print the correct number the guessed number and name
of the player
Overview Module 3 Assignment 1 features the design of a pseudocode and a Python program that...
the author's pseudocode it follows this template 3 Design the logic for a program for Nos Encanta Tu Interés credit card company that a) Allows the user to enter their name, credit card number, beginning balane and monthly interest rate b) For the next full year (12 months), 1. Outputs the month number and the balance at the beginning of the month 2. Allows the user to enter the amount of their payment, and the amount of their purchases for...
Find Bugs in the pseudocode// A high school is holding a recycling competition// This program allows a user to enter a student's // year in school (1 through 4)// and number of cans collected// Data is entered continuously until the user wnats to quit// After headings, output is four lines// one for each school year classstart Declarations num year num cans num SIZE = 4 num QUIT = 9 ...
Write a Python program (using python 3.7.2) that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows. 1. When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. (Don’t display the...
Write a python program and pseudocode The Program Using Windows Notepad (or similar program), create a file called Numbers.txt in your the same folder as your Python program. This file should contain a list on floating point numbers, one on each line. The number should be greater than zero but less than one million. Your program should read the following and display: The number of numbers in the file (i.e. count them) (counter) The maximum number in the file (maximum)...
Python Program Python: Number Guessing Game Write a Python function called "Guess.py" to create a number guessing game: 1. Function has one input for the number to Guess and one output of the number of attempts needed to guess the value (assume input number will always be between 1 and 1000). 2. If no number was given when the function was called, use random.randint(a,b) to generate a random number between a=1 and b=1000. You will also need to add an...
PLEASE DO IN PYTHON Program 2: Design (pseudocode) and implement (source code) a program (name it FeetMeters) to display a conversion tables for feet and meter as show below. Document your code and properly. Feet Meter 1.0 0.305 2.0 0.610 3.0 0.915 . . . . . . 19.0 5.7.95 20.0 6.100 Meter Feet 1.0 3.279 2.0 6.558 3.0 9.837 . . . . . . 19.0 62.301 20.0 65.574 The program defines the following methods: Method feetToMeter() converts from...
Python installation: Install Python 3 as described here. (We will work with Windows PC's.) Launch IDLE Enter the program listed in the attached file: "First program in IDLE". Save a "ProgA.py" Debug until code runs correctly. Take a screenshot of the correct output Save as "YourLastName_IDLE1.png" Upload here How do you debug # First Python Program #Fill date here # Name: Fill name here # _________________________ first = input("Enter first name:") last = input("Enter last name:") print("Hello " + first...
Turning this Pseudocode into the described C++ Program? (will include Pseudocode AND Description of the Program below!) Pseudoode: start Declarations num deptNum num salary num hrsWorked num SIZE = 7 num totalGross[SIZE] = 0 string DEPTS[SIZE] = “Personnel”, “Marketing”, “Manufacturing”, “Computer Services”, “Sales”, “Accounting”, “Shipping” getReady() while not eof detailLoop() endwhile finishUp() stop getReady() output “Enter the department number, hourly salary, and number of hours worked” input deptNum, salary, hrsWorked return detailLoop() if deptNum >= 1 AND deptNum...
Python Programming Chapter 5 Programming Exercise Dinner Selection Program (60 points total) Pseudocode (10 points) As the family cook, you know that the toughest question of the day is "What's for dinner?" You For decide to write a program to help you do days of meal planning for the entree, side and dessert. You will need to use random numbers and functions to complete the project. What's Dinner? • • • Start with a pseudocode (10 points). Write the pseudocode...
Pseudocode and PYTHON source code, thanks! Program 1: Design (pseudocode) and implement (source code) a class (name it QuadraticEquation) that represents a quadratic equation of the form of ax2+ bx + x = 0. The class defines the following variables and methods: Private data field a, b, and c that represent three coefficients. A constructor for the arguments for a, b, and c. Three get methods for a, b, and c. Method getDiscriminant()returns the discriminant value, which is disc =...