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
36 changes: 36 additions & 0 deletions EX_6_Script
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import numpy
import os
import matplotlib.pyplot as plt
os.listdir('.')
os.chdir('/Users/sampathkumarbalaji/EX_6/Intro_Biocom_ND_319_Tutorial6')
import pandas

#to parse and read txt file
UWvMSU_txt=pandas.read_csv("UWvMSU_1-22-13.txt",delimiter='\t')

#find no. of rows in the txt file
n_row = UWvMSU_txt.shape[0]
UW_cum_score = 0
MSU_cum_score = 0

#create a new data frame to have time and cummlative scores as columns
A=numpy.zeros((n_row-1,3))
cum_df=pandas.DataFrame(A,columns=['time','UW_cum_score', 'MSU_cum_score'])

#parse through every row, find team name, accumulate respective cum_score variables

for index in range(0,n_row-1):

if UWvMSU_txt.team[index] == 'UW':
UW_cum_score += UWvMSU_txt.score[index]
cum_df.UW_cum_score[index] = UW_cum_score
cum_df.MSU_cum_score[index] = MSU_cum_score
cum_df.time[index] = UWvMSU_txt.time[index]
else:
MSU_cum_score += UWvMSU_txt.score[index]
cum_df.MSU_cum_score[index] = MSU_cum_score
cum_df.UW_cum_score[index] = UW_cum_score
cum_df.time[index] = UWvMSU_txt.time[index]

#plot graph time vs cum_scores for both the teams
plt.plot(cum_df.time,cum_df.UW_cum_score,'r-',cum_df.time,cum_df.MSU_cum_score,'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

44 changes: 44 additions & 0 deletions GuessNumber
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Importation of packages and navigation to biocomputing directory.

import numpy
import os
import pandas
os.listdir('.')
os.chdir('/Users/winghomitchell/Intro_Biocom_ND_319_Tutorial6')

# Line thirteen will print a prompt for the user to read.
# Line fourteen will store the randomly generated number between 1-100 in an variable called "answer"
# Line fifteen will convert guess into an integer and prompt the user to enter a number.

print('I am thinking of a number between 1 and 100...')
answer = numpy.random.choice(100)
guess = int(input('Guess?'))

# While loop will iterate so as long as the user's guess is not equal to the randomly generated integer stored in answer.

while guess != answer:

# This block of code will execute if the guess is greater than the value stored in the answer variable.
# In the event that the guess is correct, the program will end.

if int(guess) > int(answer):
print (guess)
print('Lower...')
guess = input('Guess?')

if int(guess) == int(answer):
print (guess)
print ('Correct!')

# This block of code will execute if the guess is less than the value stored in the answer variable.
# In the event that the guess is correct, the program will end.

elif int(guess) < int(answer):
print (guess)
print ('Greater...')
guess = input('Guess?')

if int(guess) == int(answer):
print (guess)
print ('Correct!')

52 changes: 52 additions & 0 deletions guessinggamev2
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Importation of packages and navigation to biocomputing directory.

import numpy
import os
import pandas
os.listdir('.')
os.chdir('/Users/winghomitchell/Intro_Biocom_ND_319_Tutorial6')

# Line thirteen will print a prompt for the user to read.
# Line fourteen will store the randomly generated number between 1-100 in an variable called "answer"
# Line fifteen will convert guess into an integer and prompt the user to enter a number.

print('I am thinking of a number between 1 and 100...')
answer = numpy.random.choice(100)
guess = int(input('Guess?'))
count = int(1)

# While loop will iterate so as long as the user's guess is not equal to the randomly generated integer stored in answer.

while guess != answer:

# This block of code will execute if the guess is greater than the value stored in the answer variable.
# In the event that the guess is correct, the program will end.
# This version of the guessing game incorporates a simple counter to track the number of guesses required to arrive at the correct answer.

if int(guess) > int(answer):
print (guess)
print('Lower...')
guess = input('Guess?')
count = count + 1

if int(guess) == int(answer):
print (guess)
print ('Correct!')
print ('You guessed the number in %d guesses!' %(count))

# This block of code will execute if the guess is less than the value stored in the answer variable.
# In the event that the guess is correct, the program will end.
# This version of the guessing game incorporates a simple counter to track the number of guesses required to arrive at the correct answer.

elif int(guess) < int(answer):
print (guess)
print ('Greater...')
guess = input('Guess?')
count = count + 1

if int(guess) == int(answer):
print (guess)
print ('Correct!')
print ('You guessed the number in %d guesses!' %(count))

# End of script.

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