Skip to content

All the projects added in the master branch #5

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
wants to merge 53 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
7783d17
Update Project2-age.py
zwmccall Sep 28, 2017
9af92d9
fixed a typo
csurfus Sep 28, 2017
edc7a5d
twitter.py
yogithapolavarapu Sep 28, 2017
87eee92
Update Project2-age.py
yogithapolavarapu Sep 28, 2017
a718ac6
Update Project3-weeks_and_days(function).py
yogithapolavarapu Sep 28, 2017
0e6389a
Merge pull request #2 from zwmccall/patch-1
Sep 28, 2017
c5a6dfc
Merge pull request #3 from csurfus/patch-1
Sep 28, 2017
1e7990f
Merge pull request #4 from yogithapolavarapu/patch-1
Sep 28, 2017
a60cf70
Merge pull request #5 from yogithapolavarapu/patch-2
Sep 28, 2017
21c6305
Merge pull request #6 from yogithapolavarapu/patch-3
Sep 28, 2017
c150173
Create Project2-annoying_while_loop.py
Sep 28, 2017
7ee5010
Merge pull request #8 from Marwan2001/Marwan2001-patch-1
Sep 28, 2017
d0d863d
Update Project3-weeks_and_days(function).py
TheCthulhuKid Sep 28, 2017
c3181c7
Add random_house.py
pranavgoel25 Sep 28, 2017
9bfac18
Update README.md
pranavgoel25 Sep 28, 2017
3de0984
Add average_of_3_numbers.py
pranavgoel25 Sep 28, 2017
63902b4
Update Project2-age.py
meshubhangi Sep 28, 2017
9b282a1
Create To reverse the case of a string
meshubhangi Sep 28, 2017
2808155
Updating twitter.py
CrazyLlama Sep 28, 2017
f4fd4df
Create CONTRIBUTING.md
CrazyLlama Sep 28, 2017
e209bce
O(n^2) sorting algorithms
jalbertsr Sep 28, 2017
810a610
Project2-annoying-while-loop.py update
Synnennennen Sep 28, 2017
ffe4bf5
Merge pull request #9 from gileadslostson/patch-1
Sep 28, 2017
531c179
Merge pull request #12 from pranavgoel25/random_house
Sep 28, 2017
b15c0c6
Merge pull request #13 from pranavgoel25/update-readme
Sep 28, 2017
389148f
Merge pull request #14 from pranavgoel25/average_of_3
Sep 28, 2017
78d0677
Merge pull request #15 from meshubhangi/master
Sep 28, 2017
aa8d6f5
Making the code more user friendly
Sep 28, 2017
fceaba5
Merge pull request #16 from meshubhangi/patch-1
Sep 28, 2017
7b032a4
Merge pull request #17 from CrazyLlama/patch-1
Sep 28, 2017
2bb98b2
Add fizzbuzz.py
pranavgoel25 Sep 28, 2017
f9040da
Update CONTRIBUTING.md
Sep 28, 2017
487edc3
Merge pull request #18 from CrazyLlama/master
Sep 28, 2017
f26c30e
Update Project4-sorting_algorithms.py
Sep 28, 2017
8d45c9e
Merge pull request #19 from jalbertsr/master
Sep 28, 2017
4b35eb8
Merge pull request #21 from Synnennennen/patch-1
Sep 28, 2017
46e3771
Merge pull request #23 from pranavgoel25/fizzbuzz
Sep 28, 2017
7264ed2
Update README.md
Sep 28, 2017
637fd6f
Merge pull request #24 from Marwan2001/Marwan2001-patch-2
Sep 28, 2017
3c6d4ce
Update README.md
Sep 28, 2017
6bb5262
Merge pull request #26 from Marwan2001/Marwan2001-patch-3
Sep 28, 2017
8b516c2
query google with keyword, open webbrowser with results
Sep 28, 2017
70cde9a
Merge pull request #27 from beigebrucewayne/master
Sep 28, 2017
971bd80
Update README.md
HargovindArora Sep 28, 2017
f4db04b
A python game using random
HargovindArora Sep 28, 2017
da548b0
Create battleship_by_first_timer_code
Sep 28, 2017
b127a16
Merge pull request #28 from HargovindArora/patch-1
2001smj24 Sep 29, 2017
0f11e64
Update battleship_by_first_timer_code
2001smj24 Sep 29, 2017
d481e64
Merge pull request #30 from jessufgit/jessufgit-battleship
2001smj24 Sep 29, 2017
5bee35f
Merge pull request #29 from HargovindArora/random_game
2001smj24 Sep 29, 2017
7f354c1
updated the comments
yogithapolavarapu Oct 21, 2018
1f677b4
changes to comments
yogithapolavarapu Oct 21, 2018
4e1c646
Merge pull request #1 from yogithapolavarapu/yogithapolavarapu-patch-1
yogithapolavarapu Oct 21, 2018
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
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* A list of contributers to this project (Github handles) */
/*Add your name here*/

Marwan2001, yogithapolavarapu, csurfus, zwmccall, CrazyLlama
6 changes: 3 additions & 3 deletions Project2-age.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


print('Hello')
user_age = input('What is your age? \n')
user_age = int(input('What is your age? \n'))
print('Oh so your age is', user_age)
years = input('Enter a numberto know your age after that many years \n')
print('You will be', int(years)+int(user_age), 'in', years ,'years')
years = int(input('Enter a number to know your age after that many years \n'))
print('You will be',years+user_age, 'in', years ,'years')
9 changes: 9 additions & 0 deletions Project2-annoying_while_loop.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""
A never ending while_loop which never terminates
"""
"""
While True:
print("Hello World")
"""
while True:
print('Hello World')
9 changes: 4 additions & 5 deletions Project3-weeks_and_days(function).py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#This is a function.
def readable_timedelta(days):
"""To get the number of weeks and days in given nuber of days"""
number_of_weeks = days // 7 #To get number of weeks
number_of_days = days % 7 # To get number of days
return('{} week(s) and {} day(s)'.format(number_of_weeks, number_of_days))
"""To get the number of weeks and days in given number of days"""
number_of_weeks = days // 7 # To get number of weeks
number_of_days = days % 7 # To get number of days
return '{} week(s) and {} day(s)'.format(number_of_weeks, number_of_days)

82 changes: 82 additions & 0 deletions Project4-sorting_algorithms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# -*- coding: utf-8 -*-
"""
@author: jalbert
Implementation of three sorting algorithms with complexity 0(n^2) and the comparasion of time execution between them.
"""
#made using python 2

import random
from time import time

lst = [random.randint(0, 200) for x in range(50)]


def bubble_sort(array):

for i in range(len(array)):
for j in range(len(array)-1-i):
if array[j] > array[j+1]:
array[j], array[j+1] = array[j+1], array[j]
return array

def insertion_sort(array):

for i in range(len(array)):
j = i
while j > 0 and array[j] < array[j-1]:
array[j], array[j-1] = array[j-1], array[j]
j -= 1
return array

def selection_sort(array):

for slot in range(len(array)-1,0,-1):
maxpos = 0
for index in range(slot+1):
if array[index] > array[maxpos]:
maxpos = index
temp = array[slot]
array[slot] = array[maxpos]
array[maxpos] = temp
return array


t0 = time()
bubble_sort(lst)
ft0 = time()
elapsed0 = ft0 - t0

print "Bubble sort algorithm"
print "Execution time: %.10f sec" % (elapsed0)
print "==================================="

t1 = time()
insertion_sort(lst)
ft1 = time()
elapsed1 = ft1 - t1

print "Insertion sort algorithm"
print "Execution time: %.10f sec" % (elapsed1)
print "==================================="

t2 = time()
selection_sort(lst)
ft2 = time()
elapsed2 = ft2 - t2

print "Selection sort algorithm"
print "Execution time: %.10f sec" % (elapsed2)
print "===================================\n"

algorithms = {'Bubble': elapsed0, 'Insertion': elapsed1, 'Selection': elapsed2}

print "From best algorithm to worst:\n"
for key, value in sorted(algorithms.iteritems(), key=lambda (k,v): (v,k)):
print "%s: %s" % (key, value)







12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# Python_Projects
Contains projects made using Python 3.x.

You can contribute to this and make new projects.
Contains projects made using Python 3.x and a few Python 2.x (We prefer Python 3.x)

Contribute to this repo by submitting fun and exciting projects.

Help me in improving my code
Also, please help us in improving us code.

### We now have our own chat group click link bellow to join it.

Note: I am not a professional programmer I am still learning to code.
[gitter link](https://gitter.im/Python_Projects/Lobby?utm_source=share-link&utm_medium=link&utm_campaign=share-link)


**Note: This is not made by professionals although few professionals might have contributed.**


2 changes: 2 additions & 0 deletions To reverse the case of a string
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name= input('Enter a word to reverse the case of string \n')
print(name.swapcase());
14 changes: 14 additions & 0 deletions average_of_3_numbers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""
Author: Pranav Goel
Takes three float numbers and returns their average
"""

total = 0.0
number1=float(input("Enter the first number: "))
total = total + number1
number2=float(input("Enter the second number: "))
total = total + number2
number3=float(input("Enter the third number: "))
total = total + number3
average = total / 3
print ("The average is " + str(average))
48 changes: 48 additions & 0 deletions battleship_by_first_timer_code
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Made using Python 2.x

from random import randint

board = []

for x in range(0, 5):
board.append(["O"] * 5)

def print_board(board):
for row in board:
print " ".join(row)

print_board(board)

def random_row(board):
return randint(0, len(board) - 1)

def random_col(board):
return randint(0, len(board[0]) - 1)

ship_row = random_row(board)
ship_col = random_col(board)
print ship_row
print ship_col

# Everything from here on should be in your for loop
# don't forget to properly indent!
for turn in range(4):
print "Turn", turn + 1
guess_row = int(raw_input("Guess Row: "))
guess_col = int(raw_input("Guess Col: "))

if guess_row == ship_row and guess_col == ship_col:
print "Congratulations! You sank my battleship!"
break
else:
if guess_row not in range(5) or \
guess_col not in range(5):
print "Oops, that's not even in the ocean."
elif board[guess_row][guess_col] == "X":
print( "You guessed that one already." )
else:
print "You missed my battleship!"
board[guess_row][guess_col] = "X"
if (turn == 3):
print "Game Over"
print_board(board)
15 changes: 15 additions & 0 deletions fizzbuzz.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env python3

def fizz_buzz(num):
if num % 15 == 0:
print("FizzBuzz")
elif num % 5 == 0:
print("Buzz")
elif num % 3 == 0:
print("Fizz")
else:
print(num)

for i in range(1, 101):
fizz_buzz(i)

25 changes: 25 additions & 0 deletions google_searcher.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import webbrowser
import sys
import pyperclip
import requests
import bs4


def main():
if len(sys.argv) > 1:
keyword = ' '.join(sys.argv[1:])
else:
keyword = pyperclip.paste()

res = requests.get('http://google.com/search?q=' + keyword)
res.raise_for_status()
soup = bs4.BeautifulSoup(res.text, "html.parser")
linkElems = soup.select('.r a')
numOpen = min(5, len(linkElems))

for i in range(numOpen):
webbrowser.open('http://google.com' + linkElems[i].get('href'))


if __name__ == '__main__':
main()
42 changes: 42 additions & 0 deletions random_game.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import random

def get_guess():
return list(input("What is Your Guess?"))

def generate_code():
digits = [str(num) for num in range(10)]

random.shuffle(digits)

return digits[:3]

def generate_clues(code,user_guess):
clues = []
if user_guess == code:
return "CODE CRACKED!"

for ind,num in enumerate(user_guess):
if num == code[ind]:
clues.append("match")
elif num in code:
clues.append("Close")

if clues == []:
return ["Nope"]
else:
return clues

print ("Welcome Code Breaker!")

secret_code = generate_code()

clue_report = []

while clue_report != "CODE CRACKED!":

guess = get_guess()

clue_report = generate_clues(secret_code,guess)
print("here is the result of your guess:")
for clue in clue_report:
print(clue)
15 changes: 15 additions & 0 deletions random_house.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""
Author: Pranav Goel
Takes user's name as input and returns a random type of house they'll have when they grow up.
"""


import random

future = ['bungalow','mansion','villa']

name = input("What is your name?\n")

num = random.random()%3

print(name,", you'll have a ",future[int(num)]," when you grow up! :)")
34 changes: 34 additions & 0 deletions twitter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
'''
retrieves tweets from home
ofcourse! We will specify the limit
'''

import tweepy
from tweepy import OAuthHandler

# Here be main
def main():
# auth variables for keys
consumerKey = input('Enter your consumer key: ')
consumerSecret = input('Enter your consumer secret: ')
accessToken = input('Enter your access token: ')
accessSecret = input('Enter your access secret: ')

# OPEN the handle variable which acts like a cursor
handle=open('tweets.txt','w')

# Loading Auth variables
auth = tweepy.OAuthHandler(consumerKey, consumerSecret)
auth.set_access_token(accessToken, accessSecret)
api = tweepy.API(auth)

# Cursor goes through each tweet and processes the status, limit is set to 100
for status in tweepy.Cursor(api.home_timeline).items(100):
# Process a single status
print (status.text)
handle.write(status.text.encode('utf-8'))
handle.write('\n \n')
handle.close()

# Here be main starting its game
if __name__ == "__main__": main()