diff --git a/EX_6_Script b/EX_6_Script new file mode 100644 index 0000000..4e48077 --- /dev/null +++ b/EX_6_Script @@ -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-') diff --git a/GuessNumber b/GuessNumber new file mode 100644 index 0000000..ce18bd0 --- /dev/null +++ b/GuessNumber @@ -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!') + diff --git a/guessinggamev2 b/guessinggamev2 new file mode 100644 index 0000000..11fb1c3 --- /dev/null +++ b/guessinggamev2 @@ -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.