Class Assignment - for Wednesday, April 15

There will be no class in room 504 on Wednesday, April 15. The next class will be on Wednesday, April 22.

You are not required to do anything for this class. I think you will gain some programming ability if you do nothing more than attend the Wednesday sessions. However, I will make suggestions that I think would help you to learn a lot more than that. Here are some.

If you have not already installed Python on your home computer, please do so. You will need it to do this assignemnt. Call me if you would like me to walk you through installing Python on your machine (276-608-3060)

The examples page (click here) has aseveral programs related ot getting imput from the user. This is where the running program asks the user to type something in, reads what is typed on the keyboard and does something with that input.

These are :

user_input_examples.py [ You don't need everything covered in here ]
user_input_a_number
user_input_a_number_inside_a_loop.py

Study these examples and try to understand how they work. A good way to do this is to copy each file into a file on your computer, run it, and enter modifications to help show how it works.

When you think you understand how to write a program that will get a number from a user, write a program to do the following;

The program should start off by setting a value that user will try to guess. E.g.    guess_num = 24   . Then the program will use a loop to ask the uer to enter guesses for that number. The loop should keep going until the user guesses the correct number. To make it a more interesting game, modify the program to tell the user whether the last guess was too high or too low. You could even modify it to say "way too high" or "too high" depending on how far off the guess was.

Once you get that working, then, study the sample program that shows how to get a random number. Modify your guessing game progarm so that the number to be guessed is generated as a random number by the program.   Here is a link to the sample program for getting a random number.

get_a_random_number

If you have questions, or would like me to review your code, send me email at harry@baya.net.

Do you have any ideas a number, or word, game that could be programmed in Python?

Happy Coding !                                         Harry