CLA Project 5 – A guessing game 1. Log into Ranger 2. At the

Transcription

CLA Project 5 – A guessing game 1. Log into Ranger 2. At the
CLA Project 5 – A guessing game
1.
2.
3.
4.
5.
Log into Ranger
At the ranger$ prompt – type in idle3 &
In the idle shell window click on File to New File
This new window is the idle scripting window, this is where we will type the program.
Type in the following comments at the top of the program:
# Your Name
# csci 1170 – 00x
# CLAProject5
# Guessing Game
6. Now save this file to your CLA directory and call it project5.py
7. Create a program that solves the description below. Run your program several times as you
work so that you will discover any syntax errors right away.
Create a program that selects a random integer from 1 to 10. The user will then be asked over and over
to guess the number. Keep up with a running count of how many times the user has to guess. When the
user enters the matching number tell them they got it and how many tries it took.
Below is sample output from running the program 2 times.
8. Once your program is finished, we will create a script file for grading purposes. Go to the
ranger$ prompt and do each of these commands one at a time. You may need to make sure you
are in the CLA directory first (cd CLA). You need to be in the same directory as the project5.py
file. Type in ls for list to know where the file is. Be sure the correct information does display on
the screen (we need to be able to see your program code and your output)
script claProject5.log
cat –n project5.py
python3 project5.py (enter integers until you get the right one)
python3 project5.py (a second run, enter integers until you get the right one)
exit
9. Now print your script log file by typing: lph claProject5.log
10. Turn in your printout to your GTA