Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Exercis06_Part2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import random
guessesTaken=0
number= random.randint(1,100)
print('I am thinking of a number between 1 and 100')

while guessesTaken <10:
print('Guess')
guess= input()
guess= int(guess)

guessesTaken= guessesTaken + 1

if guess < number:
print ('Higher')
if guess > number:
print ('Lower')
if guess == number:
break
print('Correct!')
49 changes: 49 additions & 0 deletions Exercise06_Complete
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#To see history of edits please refer to the python scripts labelled Exercise06_Part1 and Exercis06_Part2(misspelled when naming the file)

#For Part 1

import pandas
import matplotlib.pyplot as plt

#create new dataframe of the raw data
bball= pandas.read_table('UWvMSU_1-22-13.txt',delim_whitespace=True)

#setting running cumulative scores for both teams
UWscore = [0]
MSUscore = [0]
time = [0]

#loop to match scores with teams
for i in range(0, bball.shape[0], 1):
if bball.team[i] == 'UW':
UWscore.append(UWscore[-1]+bball.score[i])
MSUscore.append(MSUscore[-1])
elif bball.team[i] == 'MSU':
MSUscore.append(MSUscore[-1]+bball.score[i])
UWscore.append(UWscore[-1])
time.append(bball.time[i])

#Line plot of both teams where 'r-' is a red line for UW and 'g-' is a green line for MSU
plt.plot(time, UWscore, 'r-', time, MSUscore, 'g-')

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job

#For Part 2

import random
guessesTaken=0
number= random.randint(1,100)
print('I am thinking of a number between 1 and 100')

while guessesTaken <10:
print('Guess')
guess= input()
guess= int(guess)

guessesTaken= guessesTaken + 1

if guess < number:
print ('Higher')
if guess > number:
print ('Lower')
if guess == number:
break
print('Correct!')

@lyy005 lyy005 Oct 12, 2017

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may want to put "print('Correct')" within the "if guess == number" so it won't print out "Correct!" when you reach the maximum guesses.

23 changes: 23 additions & 0 deletions Exercise06_Part1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import pandas
import matplotlib.pyplot as plt

#create new dataframe of the raw data
bball= pandas.read_table('UWvMSU_1-22-13.txt',delim_whitespace=True)

#setting running cumulative scores for both teams
UWscore = [0]
MSUscore = [0]
time = [0]

#loop to match scores with teams
for i in range(0, bball.shape[0], 1):
if bball.team[i] == 'UW':
UWscore.append(UWscore[-1]+bball.score[i])
MSUscore.append(MSUscore[-1])
elif bball.team[i] == 'MSU':
MSUscore.append(MSUscore[-1]+bball.score[i])
UWscore.append(UWscore[-1])
time.append(bball.time[i])

#Line plot of both teams where 'r-' is a red line for UW and 'g-' is a green line for MSU
plt.plot(time, UWscore, 'r-', time, MSUscore, 'g-')
9 changes: 9 additions & 0 deletions Exercise6-1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#Early working of part 1-not complete or correct

import pandas
import matplotlib.pyplot as plt
bball=pandas.read_table('UWvMSU_1-22-13.txt',delim_whitespace=True)
UW=bball[bball.team=='UW']
MSU=bball[bball.team=='MSU']

plt.plot('UWscore','r-','MSUscore','g-')