Dear Python Community:
I am new to Python,with only about a month's experience. I am writing
Python 3.4.0 code that apparently isn't doing what it should be doing.
Specifically, I am inputting or trying to input,a Sentry Variable to a While
Loop. I want to test out the Main program" While" Loop before I add an inner
"While" Loop. The program I have written,when run on the Python 3.4.0
Shell,does not stop for input of the "While" Sentry Variable,it just gives a
program error: "Value of smv_grandVariable undefined". What am I doing wrong
here? I'll try to post that part of the Code that is malfunctioning as well as
Python Shell 3.4.0 Traceback Analysis. Please help if you can,this program is
due on Thursday the 22nd of April,2014.
#CS 110A Spring 2014 Sect 4988 Assignment 4
#MODIFIED GUESS MY NUMBER PROGRAM
#Date April ,2014
#Programmer Stephen W. Mik
#This program is modified after a version found
#in the TextBook "Python Programming 3rd Edition"
#by Michael Dawson Copyright 2010;ISBN-13: 978-1-4354-5500-9
#Or the Alternate ISBN-10: 1-4354-5500-2.
#It is based on the material found on page 50,and pages 81-84
#of the Book, along with a downloaded basic program Structyre
#"guess_my_number" ,found in the book companion's Website Files
#"www.courseptr.com/downloads" Chapter 3.
######EXPLANATION OF GUESS MY
NUMBER###################################################
#This program uses a random number generator(supplied by Python 3.4.0) to
#to pick a changeable number between 1 and 60. The User is prompted to guess
the number
#by inputting a guess at the prompt. The user is then advised whether the
correct number
#has been guessed. If it has been guessed correctly,the user is congratulated.
If the number
#has not been guessed correctly,the attempt is noted and quantified. then the
user is told whether
# the guess number was too large (and then for the user to guess a lower
number) or the number
#guessed was too small (and in this case for the user to guess a higher
number). The number of
#attempted non-successful guesses is accumulated and totalled and then when
finally the User guesses
#the correct number ; the guess attempts are outputted along with
Congatulations. The User is queried
#if they want to play the game again,if not,the Program ends.
##########################################################################################
####MAIN PROGRAM SECTION########################
#Use the random import module for a random number between 1 and 60
import random
print("\tWelcome to the Guess My Number Game! ")
print("\n The Mysterious Number to guess is between 1 and 60. ")
print("Try to guess the Mystery Number in as few tries as you can.\n")
#Enter Main Query Loop
print("Do you want to play the game?\n")
print("Enter a 1 to play or 0 to exit:")
input(smv_grandVariable)
while (smv_grandVariable == 1 and smv_grandVariable != 0):
#Enter the play games main loop area
#Take Control of the main While Loop
print("Do you want to run the Guess My Number game again? \n")
print("IF so, 1 to play again or 0 to not play \n")
input(smv_grandVariable)
#end of main control Loop
#print out ending comments
print("Program is Ended")
input("\n\nPress the enter key to exit. ")
#End of Program
Python 3.4.0 (v3.4.0:04f714765c13, Mar 16 2014, 19:24:06) [MSC v.1600 32 bit
(Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
>>>
Welcome to the Guess My Number Game!
The Mysterious Number to guess is between 1 and 60.
Try to guess the Mystery Number in as few tries as you can.
Do you want to play the game?
Enter a 1 to play or 0 to exit:
Traceback (most recent call last):
File "E:\My Code\assignment4.py", line 37, in <module>
input(smv_grandVariable)
NameError: name 'smv_grandVariable' is not defined
>>>
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor