Skip to content
Open

Demo #112

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
200 commits
Select commit Hold shift + click to select a range
53490a1
Hello World program
soumya9988 Oct 9, 2018
a98bc5b
Merge pull request #1 from soumya9988/python_basics
soumya9988 Oct 9, 2018
99c02bd
Add basic python program
soumya9988 Oct 9, 2018
9a0ca23
Merge pull request #2 from soumya9988/python_basics
soumya9988 Oct 9, 2018
128ab98
New files added
soumya9988 Oct 9, 2018
ba6c08e
Merge pull request #3 from soumya9988/python_basics
soumya9988 Oct 9, 2018
e8ef684
New files added
soumya9988 Oct 10, 2018
2c4b9d7
Merge pull request #4 from soumya9988/python_basics
soumya9988 Oct 10, 2018
885f407
Sample python programs
soumya9988 Oct 10, 2018
bcaea62
Merge pull request #5 from soumya9988/python_basics
soumya9988 Oct 10, 2018
3d868a9
Merge pull request #6 from soumya9988/master
soumya9988 Oct 11, 2018
9762b8e
Update new program
soumya9988 Oct 11, 2018
ae99006
Merge pull request #7 from soumya9988/python_basics
soumya9988 Oct 11, 2018
48f12fa
Adding files
soumya9988 Oct 11, 2018
63b881a
Merge pull request #8 from soumya9988/python_basics
soumya9988 Oct 11, 2018
da3f2e4
Class files
soumya9988 Oct 11, 2018
c3f84ad
New files
soumya9988 Oct 11, 2018
09de3fb
Merge pull request #9 from soumya9988/python_basics
soumya9988 Oct 11, 2018
bde69b6
New files added
soumya9988 Oct 12, 2018
af45f4f
Merge pull request #10 from soumya9988/python_basics
soumya9988 Oct 12, 2018
897f8b0
New file added
soumya9988 Oct 14, 2018
ac018ac
Merge pull request #11 from soumya9988/python_basics
soumya9988 Oct 14, 2018
9c1a73a
Add new files
soumya9988 Oct 15, 2018
6ead700
Merge pull request #12 from soumya9988/python_basics
soumya9988 Oct 15, 2018
3a88863
New programs
soumya9988 Oct 16, 2018
ea7abb1
Merge pull request #13 from soumya9988/python_basics
soumya9988 Oct 16, 2018
69cfb79
Add new program files
soumya9988 Oct 17, 2018
c1a2742
Merge pull request #14 from soumya9988/python_basics
soumya9988 Oct 17, 2018
f740b79
Google python exercise
soumya9988 Oct 19, 2018
5c6941a
Merge pull request #15 from soumya9988/python_basics
soumya9988 Oct 19, 2018
447c89a
Google exercises
soumya9988 Oct 19, 2018
336bbf6
Merge pull request #16 from soumya9988/python_basics
soumya9988 Oct 19, 2018
4e7ca41
Add new file
soumya9988 Oct 24, 2018
0d41b46
Merge pull request #17 from soumya9988/python_basics
soumya9988 Oct 24, 2018
d78b51a
Assignment
soumya9988 Oct 24, 2018
c60f57c
Merge pull request #18 from soumya9988/python_basics
soumya9988 Oct 24, 2018
cffb353
Assignments
soumya9988 Oct 24, 2018
173421d
Merge pull request #19 from soumya9988/python_basics
soumya9988 Oct 24, 2018
152c85c
Assignments
soumya9988 Oct 25, 2018
90a3235
Merge pull request #20 from soumya9988/python_basics
soumya9988 Oct 25, 2018
5ab27fa
Assignments
soumya9988 Oct 28, 2018
80d09a3
Merge pull request #21 from soumya9988/python_basics
soumya9988 Oct 28, 2018
4f9dffb
Assignments
soumya9988 Oct 29, 2018
eece7a8
Merge pull request #22 from soumya9988/python_basics
soumya9988 Oct 29, 2018
932b1f7
Assignments
soumya9988 Oct 30, 2018
e79e196
Merge pull request #23 from soumya9988/python_basics
soumya9988 Oct 30, 2018
e27a5b0
Assignments
soumya9988 Oct 30, 2018
18c6681
Merge pull request #24 from soumya9988/python_basics
soumya9988 Oct 30, 2018
81d3309
Assignments
soumya9988 Oct 31, 2018
cc69a69
Merge pull request #25 from soumya9988/python_basics
soumya9988 Oct 31, 2018
39eae00
Regex program
soumya9988 Nov 2, 2018
218104a
Merge pull request #26 from soumya9988/python_basics
soumya9988 Nov 2, 2018
050bfb6
Python programs
soumya9988 Nov 9, 2018
51a70a4
Merge pull request #27 from soumya9988/python_basics
soumya9988 Nov 9, 2018
63ab7ae
Python Exercises
soumya9988 Nov 13, 2018
b9c4267
Merge pull request #28 from soumya9988/python_basics
soumya9988 Nov 13, 2018
1cade07
Add Python programs
soumya9988 Nov 15, 2018
8ef96d7
Merge pull request #29 from soumya9988/python_basics
soumya9988 Nov 15, 2018
e118884
New python examples
soumya9988 Nov 28, 2018
a6f13f7
Merge pull request #30 from soumya9988/python_basics
soumya9988 Nov 28, 2018
e0c1294
Sample Python program
soumya9988 Nov 29, 2018
e56a5b5
Merge pull request #31 from soumya9988/python_basics
soumya9988 Nov 29, 2018
1829c53
Python program
soumya9988 Dec 3, 2018
a9cc0b3
Merge pull request #32 from soumya9988/python_basics
soumya9988 Dec 3, 2018
1d77eaa
Python programs
soumya9988 Dec 6, 2018
59e0ebb
Merge pull request #33 from soumya9988/python_basics
soumya9988 Dec 6, 2018
6f5e30a
Python basics
soumya9988 Dec 8, 2018
4c187cf
Merge pull request #34 from soumya9988/python_basics
soumya9988 Dec 8, 2018
1d82ffe
Python basics
soumya9988 Dec 12, 2018
6a2129e
Merge pull request #35 from soumya9988/python_basics
soumya9988 Dec 12, 2018
b56c5f6
Automate boring stuff
soumya9988 Dec 12, 2018
c3307ee
Merge pull request #36 from soumya9988/python_basics
soumya9988 Dec 12, 2018
3d97260
Python class
soumya9988 Dec 20, 2018
b8fd0a2
Merge pull request #37 from soumya9988/python_basics
soumya9988 Dec 20, 2018
008e509
Python program
soumya9988 Jan 14, 2019
cd4a0e7
Merge pull request #38 from soumya9988/python_basics
soumya9988 Jan 14, 2019
8b45284
Automate boring stuff
soumya9988 Jan 15, 2019
be27b6c
Merge pull request #39 from soumya9988/python_basics
soumya9988 Jan 15, 2019
97f687e
Automate Boring Stuffs
soumya9988 Jan 17, 2019
7fab2ad
Merge pull request #40 from soumya9988/python_basics
soumya9988 Jan 17, 2019
4d933dd
Automate boring stuffs
soumya9988 Jan 22, 2019
05a132d
Merge pull request #41 from soumya9988/python_basics
soumya9988 Jan 22, 2019
fe8d11e
Automate boring stuff
soumya9988 Jan 23, 2019
9bca99c
Merge pull request #42 from soumya9988/python_basics
soumya9988 Jan 23, 2019
f79f23e
Delete quiz_data.py
soumya9988 Jan 23, 2019
68bea8f
Automate Boring Stuffs
soumya9988 Jan 23, 2019
af240ce
Merge pull request #43 from soumya9988/python_basics
soumya9988 Jan 23, 2019
2816a72
Automate Boring Stuffs
soumya9988 Jan 25, 2019
b31c3e1
Merge pull request #44 from soumya9988/python_basics
soumya9988 Jan 25, 2019
37c6546
Automate Boring stuffs
soumya9988 Jan 29, 2019
a3f2996
Merge pull request #45 from soumya9988/python_basics
soumya9988 Jan 29, 2019
3832cfd
Automate Boring Stuffs
soumya9988 Feb 4, 2019
9e68a8b
Merge pull request #46 from soumya9988/python_basics
soumya9988 Feb 4, 2019
fd82eb2
Automate Boring Stuffs
soumya9988 Feb 6, 2019
dddee63
Automate Boring Stuffs
soumya9988 Feb 7, 2019
8be7940
Merge pull request #47 from soumya9988/python_basics
soumya9988 Feb 7, 2019
bac81a6
Automate Boring Stuffs
soumya9988 Feb 8, 2019
2688a46
Merge pull request #48 from soumya9988/python_basics
soumya9988 Feb 8, 2019
aa4e0e2
Automate Boring Stuffs
soumya9988 Feb 11, 2019
c9bf855
Merge pull request #49 from soumya9988/python_basics
soumya9988 Feb 11, 2019
5084d41
Automate Boring Stuffs
soumya9988 Feb 12, 2019
e008fbe
Merge pull request #50 from soumya9988/python_basics
soumya9988 Feb 12, 2019
a77886f
Automate the boring Stuffs
soumya9988 Feb 19, 2019
53df36a
Merge pull request #51 from soumya9988/python_basics
soumya9988 Feb 19, 2019
969fae0
Delete sample_file.jpg
soumya9988 Feb 19, 2019
0240088
Delete sample_file1.jpg
soumya9988 Feb 19, 2019
edcce2e
Delete sample_file2.jpg
soumya9988 Feb 19, 2019
2c21271
Python Assignemts
soumya9988 Feb 20, 2019
43fd000
Merge pull request #52 from soumya9988/python_basics
soumya9988 Feb 20, 2019
1546fec
Python Assignemts
soumya9988 Feb 20, 2019
eedc1e3
Python Assignemts
soumya9988 Feb 20, 2019
cfc3536
Merge pull request #53 from soumya9988/python_basics
soumya9988 Feb 20, 2019
0061335
Automate Boring Stuffs
soumya9988 Feb 21, 2019
518a614
Merge pull request #54 from soumya9988/python_basics
soumya9988 Feb 21, 2019
c57896c
Add Udemy exercises
soumya9988 Mar 27, 2019
538d14b
Merge pull request #55 from soumya9988/python_basics
soumya9988 Mar 27, 2019
b0f52ad
Machine Learning
soumya9988 Mar 27, 2019
7dcc41e
Merge pull request #56 from soumya9988/python_basics
soumya9988 Mar 27, 2019
b83e014
ML in UDemy
soumya9988 Mar 29, 2019
7029c58
Merge pull request #57 from soumya9988/python_basics
soumya9988 Mar 29, 2019
9be96e1
ML in UDemy
soumya9988 Mar 29, 2019
aefc268
UDemy ML
soumya9988 Apr 1, 2019
945de1a
Merge pull request #58 from soumya9988/python_basics
soumya9988 Apr 1, 2019
cbfae9b
Udemy Tutorials
soumya9988 May 29, 2019
0cfce48
Merge pull request #59 from soumya9988/python_basics
soumya9988 May 29, 2019
43c40a9
ML Udemy
soumya9988 Jul 2, 2019
d3a7784
Merge pull request #60 from soumya9988/python_basics
soumya9988 Jul 2, 2019
7764010
Delete .env
soumya9988 Jul 2, 2019
d71bbe0
Delete set_variabes.py
soumya9988 Jul 2, 2019
960d4a6
Delete sample.py
soumya9988 Jul 2, 2019
802232c
Delete requirements.txt
soumya9988 Jul 2, 2019
90a5597
Delete interactive_python.py
soumya9988 Jul 2, 2019
f1cb55c
Delete interactive_by_signaling_entrance.py
soumya9988 Jul 2, 2019
043e159
Delete app.py
soumya9988 Jul 2, 2019
c4f7a84
Delete interactive_python.cpython-37.pyc
soumya9988 Jul 2, 2019
5fbb084
Delete sample.py
soumya9988 Jul 2, 2019
e2db88c
Delete requirements.txt
soumya9988 Jul 2, 2019
1a3fedf
Delete app.py
soumya9988 Jul 2, 2019
84356ec
Delete .env.template
soumya9988 Jul 2, 2019
76ab287
Delete .Python
soumya9988 Jul 2, 2019
8594e6a
Python Hobby Projects
soumya9988 Jul 3, 2019
707f998
Merge pull request #61 from soumya9988/python_basics
soumya9988 Jul 3, 2019
26acb06
Delete basics_twilio.py
soumya9988 Jul 8, 2019
a9ed8bc
ML Udemy
soumya9988 Jul 8, 2019
faa4979
Merge pull request #62 from soumya9988/python_basics
soumya9988 Jul 8, 2019
4d04af3
ML Udemy
soumya9988 Jul 8, 2019
b1b4f39
Merge pull request #63 from soumya9988/python_basics
soumya9988 Jul 8, 2019
7eb3345
ML UDemy
soumya9988 Jul 10, 2019
0e0c368
Merge pull request #64 from soumya9988/python_basics
soumya9988 Jul 10, 2019
129c8a5
ML UDemy
soumya9988 Jul 10, 2019
d2e85d5
Merge pull request #65 from soumya9988/python_basics
soumya9988 Jul 10, 2019
db8de8d
ML UDemy
soumya9988 Jul 10, 2019
54953df
ML UDemy
soumya9988 Jul 10, 2019
8440bcd
ML Udemy
soumya9988 Jul 11, 2019
f783dd7
ML Udemy
soumya9988 Jul 12, 2019
96074c9
ML Udemy
soumya9988 Jul 12, 2019
c04b8fd
ML Udemy
soumya9988 Jul 15, 2019
b60de04
ML Udemy
soumya9988 Jul 23, 2019
f1917a5
ML Udemy
soumya9988 Sep 16, 2019
19ba9a6
ML Udemy
soumya9988 Sep 18, 2019
29b205e
ML Udemy
soumya9988 Sep 19, 2019
3edf86e
ML Udemy
soumya9988 Sep 22, 2019
a8bee09
ML Udemy
soumya9988 Sep 25, 2019
840dbea
ML Udemy
soumya9988 Oct 1, 2019
77e224b
ML Udemy
soumya9988 Oct 3, 2019
e2da514
ML Udemy
soumya9988 Oct 9, 2019
77e0d81
Basics of Python Programming
soumya9988 Oct 9, 2019
c17e501
Machine Learning: UDemy
soumya9988 Oct 9, 2019
b4e836d
Machine Learning: UDemy
soumya9988 Oct 9, 2019
355ff7a
Machine Learning: Udemy
soumya9988 Oct 9, 2019
a456e79
Machine Learning: Udemy
soumya9988 Oct 10, 2019
df629d6
Machine Learning: Udemy
soumya9988 Oct 10, 2019
7b4d7b2
Basics of Python
soumya9988 Oct 10, 2019
43a0baa
Python Basics: Udemy
soumya9988 Oct 11, 2019
b66be86
Python Basics: Udemy
soumya9988 Oct 12, 2019
2b440d5
Basics of Python: Udemy
soumya9988 Oct 13, 2019
51c5718
Python Sample Applications
soumya9988 Oct 15, 2019
c434344
Basics of Python: Udemy
soumya9988 Oct 16, 2019
8c68371
Basics of Python: Udemy
soumya9988 Oct 17, 2019
a6ddff0
Basics of Python: Udemy
soumya9988 Oct 17, 2019
e3f819d
Python Sample Applications
soumya9988 Oct 18, 2019
3c7e388
Python Sample Applications
soumya9988 Oct 18, 2019
9c9e8b6
Python Sample Application
soumya9988 Oct 19, 2019
87932e0
Basics of Python: Udemy
soumya9988 Oct 21, 2019
f9a2720
Python Sample Applications
soumya9988 Oct 21, 2019
5011a46
DB Query with Python
soumya9988 Oct 22, 2019
0040801
Basics of tkinter
soumya9988 Oct 22, 2019
b328cf4
Python Sample Applications
soumya9988 Oct 28, 2019
240e446
Basics of OOP
soumya9988 Oct 31, 2019
514e207
Basics of OOP
soumya9988 Oct 31, 2019
26bb2ee
Coursera: Python Specialization for All
soumya9988 Nov 2, 2019
b66fed5
Coursera: Python Specialization for All
soumya9988 Nov 5, 2019
3145e5d
Coursera: Python Specialization for All
soumya9988 Nov 6, 2019
978c778
Coursera: Python Specialization for All
soumya9988 Nov 7, 2019
a81b30d
Coursera: Python Specialization for All
soumya9988 Nov 7, 2019
2e1ccf7
Coursera: Python Specialization for All
soumya9988 Nov 12, 2019
a66a721
Python Basics
soumya9988 Nov 14, 2019
e4a5844
Basics of Python: Course from Udemy
soumya9988 Nov 16, 2019
7d6f105
Basics of Python
soumya9988 Nov 16, 2019
d537a25
Basics of Python Language
soumya9988 Nov 16, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
Binary file added .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion .idea/hobby_python_proj.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

745 changes: 731 additions & 14 deletions .idea/workspace.xml

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions Python_basics/10_Misc/basics_flask.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/python

# Import the flask module
from flask import Flask

app = Flask(__name__)


@app.route('/')
def hello():
return 'Hello World'


# Main module
if __name__ == '__main__':
# start the app on local host.
app.run(host='127.0.0.1', port=5000)

17 changes: 17 additions & 0 deletions Python_basics/10_Misc/basics_of_nltk.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from nltk import sent_tokenize, word_tokenize
from nltk.corpus import stopwords
import PyPDF2

with open('sample_resume.pdf', 'rb') as pdf_object:
pdf_reader = PyPDF2.PdfFileReader(pdf_object)
text = pdf_reader.getPage(0).extractText()

sentences = sent_tokenize(text)
print(sentences)

words = word_tokenize(text)

stop_words = set(stopwords.words('english'))
words_req = [word for word in words if word not in stop_words]
print(words_req)

6 changes: 6 additions & 0 deletions Python_basics/10_Misc/basics_of_numpy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import numpy as np

weight_kg = [60.9, 35, 76.4, 2.80, 67.14]
np_weight_kg= np.array(weight_kg)
np_weight_lb = np_weight_kg * 2.2
print(np_weight_lb)
11 changes: 11 additions & 0 deletions Python_basics/10_Misc/io_pickle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import pickle
shop_list = ['apple', 'banana', 'flour', 'butter', 'berries', 'salmon', 'cheese', 'milk']
shop_list.sort()

with open('shopping_list.data', 'wb') as shop_file:
pickle.dump(shop_list, shop_file)

del shop_list
with open('shopping_list.data', 'rb') as shop_file:
storedlist = pickle.load(shop_file)
print(storedlist)
21 changes: 21 additions & 0 deletions Python_basics/10_Misc/resume_parser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from nltk import word_tokenize, pos_tag, sent_tokenize
import PyPDF2
import re
resume = []

with open('sample_resume.pdf', 'rb') as pdf_object:
pdf_reader = PyPDF2.PdfFileReader(pdf_object)
text = pdf_reader.getPage(0).extractText()


lines = [line.strip() for line in text.split('\n') if len(line) > 0]
lines = [word_tokenize(line) for line in lines]
lines = [pos_tag(line) for line in lines]
for line in lines:
resume += line
print(resume)

#pattern = re.compile(r'\w+@[A-Z0-9]+\.[a-z]{2,4}', re.IGNORECASE)
#email_id = pattern.findall(resume)
#print(email_id)

Binary file added Python_basics/10_Misc/sample_resume.pdf
Binary file not shown.
Binary file added Python_basics/10_Misc/shopping_list.data
Binary file not shown.
5 changes: 5 additions & 0 deletions Python_basics/1_Basics/HelloWorld.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
print('Hello World')




43 changes: 43 additions & 0 deletions Python_basics/1_Basics/python_basics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import sys

def print_arg():
print(sys.argv)


def repeat_exclaim(word, exclaim):
print_str = 'Hello'
print_str += 'there'
print(print_str)
for letter in print_str:
print(letter, end=',')
print((word * 3), end='')
if exclaim:
print('!!!')
print('-' * 20)


def sort_alpha_num(s):
i = s.split(None, 1)[0]
if i.isnumeric():
return int(i)
return s


def main():
print_arg()
repeat_exclaim('Hello ', True)
line = input('Enter the sentence separated by space: ')
list_words = line.split(' ')
set_word = set(list_words)
set_word = sorted(set_word, key=sort_alpha_num, reverse=True)
print(', '.join(set_word))
sys.exit(0)


if __name__ == '__main__':
main()





124 changes: 124 additions & 0 deletions Python_basics/1_Basics/tictactoe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
''' Program recreating the classic tic-tac-toe game between two players.
User has to input the coordinates where they wish to place there mark.
Coordinates starts at [0,0].
Game continues as long as there is a winner or the user type 'quit' to exit
Author: Soumya Narayanan '''


import copy
a = []
b = []
player = 1


def build_board(num, size):
# Building the board:
for i in range(0, size):
print(' ---' * size)
new_row = ""
for j in range(0, size):
new_row += str(num[i][j])
print("| " + " | ".join(new_row) + " | ")
print(' ---' * size)


def line_check(b, size):
for i in range(0, size):
set_r = set(b[i])
if len(set_r) == 1 and b[i][0] != 0:
return b[i][0]
return 0


def diagonal_winner(b, size):
diag = []
for i in range(0, size):
diag.append(b[i][i])
set_d = set(diag)
if len(set_d) == 1 and b[0][0] != 0:
return b[0][0]
else:
return 0


def player_switch(cur_player):
if cur_player == 1:
cur_player = 2
else:
cur_player = 1
return cur_player


# Getting the user input for the size of the board
size = int(input('Please enter the size of the board: '))
for i in range(0, size):
a = []
for j in range(0, size):
a.append(0)
b.append(a)

# Printing the initial board
build_board(b, size)

# Starting the game and continue as long as there is a winner or the user wist to:
while True:

# Getting the coordinates from the user
coordinates = [int(n, 10) for n in input('Enter the row and column separated by comma: ').split(",")]
row_num = coordinates[0]
col_num = coordinates[1]

if b[row_num][col_num] == 0:
# Assigning player value to the coordinates user selected and printing the board
b[row_num][col_num] = player
build_board(b, size)

# Check if there is a winner in any of the rows of the board:
winner_row = line_check(b, size)
if winner_row > 0:
print('Congrats!! Winner is: ', player)
break

# Transposing the list to check for column wise winner:
c = [list(i) for i in zip(*b)]
winner_col = line_check(c, size)
if winner_col > 0:
print('Congrats!! Winner is: ', player)
break

# checking for the winner diagonally
winner_diag = diagonal_winner(b, size)
if winner_diag > 0:
print('Congrats!! Winner is: ', player)
break

# check for the winner in the opposite diagonal
rev = []
copy_b = copy.deepcopy(b)
for i in range(0, size):
copy_b[i].reverse()
rev.append(copy_b[i])
winner_rev_diag = diagonal_winner(rev, size)
if winner_rev_diag > 0:
print('Congrats!! Winner is: ', player)
break

# Switching the turn to the next player
player = player_switch(player)

else:
print('There is already an entry in that place.. ')

# Check with user if they want to continue with the game:
continue_game = input('Type quit to quit!!').lower()
if continue_game == 'quit':
break









46 changes: 46 additions & 0 deletions Python_basics/1_Basics/turtle_race.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import turtle


def draw_shapes(ref, no_of_sides, length_of_sides):
"""
(int, int) --> None
A function that accepts the no of sides of a regular polygon and the length of each side and draw the polygon.

"""
angle = 360 / no_of_sides # Angle of the polygon.
ref.color('green')
ref.fillcolor('red')
ref.begin_fill()
for i in range(no_of_sides):
ref.forward(length_of_sides)
ref.left(angle)
ref.end_fill()


if __name__ == "__main__":
scr = turtle.Screen()
turtle_ref = turtle.Turtle()
draw_shapes(turtle_ref, 3, 120)
turtle_ref.penup()
turtle_ref.goto(100,100)
turtle_ref.pendown()
draw_shapes(turtle_ref, 4, 120)
turtle_ref.penup()
turtle_ref.goto(-100,-100)
turtle_ref.pendown()
draw_shapes(turtle_ref, 6, 70)
turtle_ref.penup()
turtle_ref.goto(-100,100)
turtle_ref.pendown()
draw_shapes(turtle_ref, 8, 70)
turtle_ref.penup()
turtle_ref.goto(50,-250)
turtle_ref.pendown()
draw_shapes(turtle_ref, 20, 20)
scr.exitonclick()






17 changes: 17 additions & 0 deletions Python_basics/2_FlowControl/binary_search.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from random import sample
elements = [item for item in sample(range(1, 1000), 15)]
elements.sort()
print("Elements in the list are", elements)
choice = int(input('Enter the number to be searched: '))
while True:
mid = int(len(elements) / 2)
if choice == elements[mid]:
print('Element found in the list')
break
elif choice > elements[mid]:
elements = elements[mid::]
else:
elements = elements[0:mid:]
if mid == 0:
print('Sorry, element could not be found in the list!!')
break
20 changes: 20 additions & 0 deletions Python_basics/2_FlowControl/coin_flipping.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from random import randint
times = int(input('Please enter the number of times you want to flip the coin: '))
result = ""
heads = 0
tails = 0


while times > 0:
times -= 1
coin = randint(1,2)
if coin == 1:
heads += 1
result += 'H'
else:
tails += 1
result += 'T'


print('The result after flipping the coin is:', result)
print('Heads : %d, Tails : %d' % (heads, tails))
30 changes: 30 additions & 0 deletions Python_basics/2_FlowControl/conditional_stmnt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
number = 25
guess = int(input("Enter your guess: "))
if number == guess:
print('Correctly guessed')
elif number < guess:
print(' Your guess is higher than number')
else:
print('Your guess is lower than number')
print('Out of guess logic for if!')


while True:
guess = int(input('Enter your guess:'))

if guess < 10:
print('Guessed value is too small!!')
continue
if guess < number:
print('Guess is less than number')
elif guess == number:
print('Correct guess')
break
else:
print('Guess is greater than number')

print('Out of guess block for while')


for i in range(0,10):
print(i)
Loading