Difference between revisions of "SBR600 Python Lab"

From CDOT Wiki
Jump to: navigation, search
(Created page with 'Here is a small Python script: #!/usr/bin/python import random secret=random.randrange(1,100) guess=int(raw_input("Enter a guess: ")) if guess<secret: print "Too…')
 
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
Here is a small Python script:
+
[[Category:SBR600 Labs]]
 
+
# Login to Matrix
#!/usr/bin/python
+
# Clone the "guess" python repository: <code>git clone ~chris.tyler/public/guess</code>
+
# Modify the script according to the comments at the top
import random
+
# Blog it! Include your script, the challenges you faced making the modifications, and your impressions of Python
secret=random.randrange(1,100)
 
 
guess=int(raw_input("Enter a guess: "))
 
 
if guess<secret:
 
    print "Too low!"
 
elif guess>secret:
 
    print "Too high!"
 
else:
 
    print "Correct!"
 
 
 
# Save this script, set the permissions correctly, and run it.
 
# Modify the script so that the user is given playing instructions before the game starts.
 
# Make the script loop to prompt for input until the the correct number is guessed.
 
# Displays the number of guesses the user took to guess the secret (score).
 
# Modify the script so that it does not stop when invalid data is entered (such as a word). Suggestion: use try/except.
 
# Accept only input value from 1 to 100.
 
# Write a blog entry giving your impressions of Python.
 

Latest revision as of 10:28, 3 October 2013

  1. Login to Matrix
  2. Clone the "guess" python repository: git clone ~chris.tyler/public/guess
  3. Modify the script according to the comments at the top
  4. Blog it! Include your script, the challenges you faced making the modifications, and your impressions of Python