From 70b0a53ca1d03b3a8ab95945371f587f165754e3 Mon Sep 17 00:00:00 2001 From: ayamasaki2011 Date: Fri, 29 Sep 2017 10:48:33 -0400 Subject: [PATCH 1/6] AEY: Add file for guessing game script to repo --- NumberGuess.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100755 NumberGuess.py diff --git a/NumberGuess.py b/NumberGuess.py new file mode 100755 index 0000000..e69de29 From 9ede5c960cfdc324c5200efa11514a9b39c6ea1f Mon Sep 17 00:00:00 2001 From: ayamasaki2011 Date: Fri, 29 Sep 2017 11:03:14 -0400 Subject: [PATCH 2/6] AEY: Modify game to generate a random # from 1-100 --- NumberGuess.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/NumberGuess.py b/NumberGuess.py index e69de29..e4ba288 100755 --- a/NumberGuess.py +++ b/NumberGuess.py @@ -0,0 +1,9 @@ +#"Guess my Number" game +#Takes user input of a number from 1-100 and compares it to a randomly-generated value +#Tells user if their guess is higher or lower than the correct answer +#User may keep guessing until they get the correct value + +import numpy +range=numpy.arange(1,101) #define array of possible number choices to exclude 0 and include 100 +answer=numpy.random.choice(range) #generate a random number guess + From 60db90738854b328be0b5ca3b95cdb7b565f7852 Mon Sep 17 00:00:00 2001 From: ayamasaki2011 Date: Fri, 29 Sep 2017 11:22:56 -0400 Subject: [PATCH 3/6] AEY: Add while loop to test user input against answer - doesn't work yet, though --- NumberGuess.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/NumberGuess.py b/NumberGuess.py index e4ba288..d12bece 100755 --- a/NumberGuess.py +++ b/NumberGuess.py @@ -7,3 +7,16 @@ range=numpy.arange(1,101) #define array of possible number choices to exclude 0 and include 100 answer=numpy.random.choice(range) #generate a random number guess +print("I'm thinking of a number from 1-100. Take a guess!") #Initiate game +guess=input(prompt="Your guess:") #Store a guess from the user + +while guess != answer: #Test if the user input is right + if guess < answer: #If not, test whether the guess is lower or higher than the answer + print(guess," is lower than my number.") + guess=input(prompt="Guess again:") + elif guess > answer: + print(guess," is higher than my number.") + guess=input(prompt="Guess again:") + +print(guess," is the right answer!") #If the answer is correct, let the user know + From 483538dec09d0d78c4017ce5adf97dd7c1c9ab5f Mon Sep 17 00:00:00 2001 From: Joe C Date: Sun, 1 Oct 2017 17:36:07 -0400 Subject: [PATCH 4/6] Question 1 JC - completed with no loop --- question1.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 question1.py diff --git a/question1.py b/question1.py new file mode 100755 index 0000000..f4ad43f --- /dev/null +++ b/question1.py @@ -0,0 +1,18 @@ +#load file +import pandas +file=pandas.read_csv("UWvMSU_1-22-13.txt",header=0,sep="\t") +#making a UW only table +UWscore=file[file.team == 'UW'] +#making a MSU only table +MSUscore=file[file.team == 'MSU'] +#cumulative sum of scores +new = UWscore['cum_sum'] = UWscore.score.cumsum() +new2 = MSUscore['cum_sum'] = MSUscore.score.cumsum() +import matplotlib.pyplot as plt +plt.plot(UWscore['time'], UWscore['cum_sum'], 'r-', MSUscore['time'], MSUscore['cum_sum'], 'g-') + + + + + + From a583b7c17e411e3d4ef9d16b0e3de352110e0c35 Mon Sep 17 00:00:00 2001 From: ayamasaki2011 Date: Thu, 5 Oct 2017 00:05:19 -0400 Subject: [PATCH 5/6] Ensure script takes input as an integer --- NumberGuess.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/NumberGuess.py b/NumberGuess.py index d12bece..91e6f05 100755 --- a/NumberGuess.py +++ b/NumberGuess.py @@ -6,17 +6,18 @@ import numpy range=numpy.arange(1,101) #define array of possible number choices to exclude 0 and include 100 answer=numpy.random.choice(range) #generate a random number guess +guess=0 #clear variable from the last game print("I'm thinking of a number from 1-100. Take a guess!") #Initiate game -guess=input(prompt="Your guess:") #Store a guess from the user +guess=int(input(prompt="Your guess:")) #Store a guess from the user while guess != answer: #Test if the user input is right if guess < answer: #If not, test whether the guess is lower or higher than the answer - print(guess," is lower than my number.") - guess=input(prompt="Guess again:") + print guess, "is lower than my number." + guess=int(input(prompt="Guess again:")) elif guess > answer: - print(guess," is higher than my number.") - guess=input(prompt="Guess again:") + print guess, "is higher than my number." + guess=int(input(prompt="Guess again:")) -print(guess," is the right answer!") #If the answer is correct, let the user know +print guess, "is the right answer!" #If the answer is correct, let the user know From 7bb92bfe09adfcc1f4b17125a8e6ee8304e0dfa0 Mon Sep 17 00:00:00 2001 From: ayamasaki2011 Date: Thu, 5 Oct 2017 18:11:02 -0400 Subject: [PATCH 6/6] Combine scripts into one file: Exercise6.py --- Exercise6.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Exercise6.py diff --git a/Exercise6.py b/Exercise6.py new file mode 100644 index 0000000..f640d11 --- /dev/null +++ b/Exercise6.py @@ -0,0 +1,39 @@ +#Part 1 +#load file +import pandas +file=pandas.read_csv("UWvMSU_1-22-13.txt",header=0,sep="\t") +#making a UW only table +UWscore=file[file.team == 'UW'] +#making a MSU only table +MSUscore=file[file.team == 'MSU'] +#cumulative sum of scores +new = UWscore['cum_sum'] = UWscore.score.cumsum() +new2 = MSUscore['cum_sum'] = MSUscore.score.cumsum() +import matplotlib.pyplot as plt +plt.plot(UWscore['time'], UWscore['cum_sum'], 'r-', MSUscore['time'], +MSUscore['cum_sum'], 'g-') + +#Part 2 +#"Guess my Number" game +#Takes user input of a number from 1-100 and compares it to a randomly-generated value +#Tells user if their guess is higher or lower than the correct answer +#User may keep guessing until they get the correct value + +import numpy +range=numpy.arange(1,101) #define array of possible number choices to exclude 0 and include 100 +answer=numpy.random.choice(range) #generate a random number guess +guess=0 #clear variable from the last game + +print("I'm thinking of a number from 1-100. Take a guess!") #Initiate game +guess=int(input(prompt="Your guess:")) #Store a guess from the user + +while guess != answer: #Test if the user input is right + if guess < answer: #If not, test whether the guess is lower or higher than the answer + print guess, "is lower than my number." + guess=int(input(prompt="Guess again:")) + elif guess > answer: + print guess, "is higher than my number." + guess=int(input(prompt="Guess again:")) + +print guess, "is the right answer!" #If the answer is correct, let the user know +