-
Notifications
You must be signed in to change notification settings - Fork 10
sampathkumar-mitchell submission #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
bsampath17
wants to merge
6
commits into
lyy005:master
Choose a base branch
from
bsampath17:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3185342
Question 2 for Exercise 6. A guessing game! -Thomas
twhmitchell a0d620d
Added updated version for the guessing game, second part of the sixth…
twhmitchell 88b1c15
Fixed off-by-one error on added counter. -Thomas
twhmitchell f2c99c8
Code for Question 1 - Balaji
bsampath17 6fb9949
Merge branch 'master' of https://github.com/bsampath17/Intro_Biocom_N…
bsampath17 db75ad7
Code for Question 1 - Balaji
bsampath17 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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-') | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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!') | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good job |
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job