>", image_border)
139 | # create canvas to display image
140 | canvas2 = Canvas(root, width="600", height="420", relief=RIDGE, bd=2)
141 | canvas2.place(x=15, y=150)
142 | # create buttons
143 | btn1 = Button(root, text="Select Image", bg='black', fg='gold', font=('ariel 15 bold'), relief=GROOVE, command=selected)
144 | btn1.place(x=100, y=595)
145 | btn2 = Button(root, text="Save", width=12, bg='black', fg='gold', font=('ariel 15 bold'), relief=GROOVE, command=save)
146 | btn2.place(x=280, y=595)
147 | btn3 = Button(root, text="Exit", width=12, bg='black', fg='gold', font=('ariel 15 bold'), relief=GROOVE, command=root.destroy)
148 | btn3.place(x=460, y=595)
149 | root.mainloop()
--------------------------------------------------------------------------------
/Program To Check Voter's Eligbility.py:
--------------------------------------------------------------------------------
1 | #Python Program To Check Voter's Eligblity
2 | age = int(input("Enter Your Age: "))
3 |
4 | if age > 18:
5 | print("You Are Eligible To Vote Now")
6 | elif age < 18:
7 | print("You Are Not Eligible To Vote Now")
8 | else:
9 | print("Invalid Input, Try Again")
10 |
--------------------------------------------------------------------------------
/Python Program To Display Calender.py:
--------------------------------------------------------------------------------
1 | #Importing Calender Module
2 | import calendar
3 | #Taking Data Of Year By User
4 | Year = int(input("Enter The Year To Display Calender: "))
5 | #Taking Data Of Month
6 | Month = int(input("Enter the Month: "))
7 | print(calendar.month(Year,Month))
8 |
--------------------------------------------------------------------------------
/Python Program To Secure Password/README.txt:
--------------------------------------------------------------------------------
1 | Password Secure Program For Begginers.
2 |
3 | For More Source Codes Of Python Programs
4 | Follow Me On GitHub and Instagram @mrprogrammer21.
5 |
--------------------------------------------------------------------------------
/Python Program To Secure Password/main.py:
--------------------------------------------------------------------------------
1 | #Python Program To Secure Your Password
2 | #Suggest a Good Password For Your Account
3 |
4 | Secure = (('s','$'),('and','&'),
5 | ('a','@'),('o','0'),('i','1'),
6 | ('i','#'))
7 |
8 | #Creating a Python Funtion
9 | def SecurePass(password):
10 | for a,b in Secure:
11 | password = password.replace(a,b)
12 | return password
13 |
14 | if __name__ == "__main__":
15 | password = input("Enter the Password: ")
16 | password = SecurePass(password)
17 | print("Your Password Is: {password}")
18 |
--------------------------------------------------------------------------------
/Rainbow Pattern Using Python/README.md:
--------------------------------------------------------------------------------
1 | # Rainbow Using Python Turtle
2 |
3 | Create a Rainbow Design Using Python Turtle Graphics.
4 |
5 | # Documentation
6 | Modules Used In this Project ➡
7 |
8 | 🔸 Python Turtle Graphics
9 |
10 | ## Authors
11 |
12 | - [@TanmayProgrammer-13](https://github.com/TanmayProgrammer-13)
13 |
14 |
--------------------------------------------------------------------------------
/Rainbow Pattern Using Python/main.py:
--------------------------------------------------------------------------------
1 | # Importing Required Modules
2 | import turtle
3 |
4 | # Turtle Object
5 | sc = turtle.Screen()
6 |
7 | # Creating an Object(pen)
8 | pen = turtle.Turtle()
9 |
10 |
11 | def semi_circle(col, rad, val):
12 |
13 | # Filling the Semicolor
14 | pen.color(col)
15 |
16 | # Drawing a Circle
17 | pen.circle(rad, -180)
18 |
19 | # Move the turtle to air
20 | pen.up()
21 |
22 |
23 | pen.setpos(val, 0)
24 |
25 | # Move the Turtle
26 | pen.down()
27 |
28 | pen.right(180)
29 |
30 |
31 | # Assigning Colors to the Rainbow
32 | col = ['violet', 'indigo', 'blue',
33 | 'green', 'yellow', 'orange', 'red']
34 |
35 | # Setup Screen Features For Turtle
36 | sc.setup(600, 600)
37 |
38 | # Setting Background Color to Black
39 | sc.bgcolor('black')
40 |
41 | # Adding Turtle Features
42 | pen.right(90)
43 | pen.width(10)
44 | pen.speed(7)
45 |
46 | # Running Loop For 7 Times
47 | for i in range(7):
48 | semi_circle(col[i], 10*(
49 | i + 8), -10*(i + 1))
50 |
51 | # Hide the turtle
52 | pen.hideturtle()
--------------------------------------------------------------------------------
/Screen Recorder Using Python/README.md:
--------------------------------------------------------------------------------
1 | # Screen Recorder Python
2 |
3 | Screen Recorder Using Python.
4 |
5 | ## Documentation
6 |
7 | Modules Used In This Project:-
8 |
9 | 🔸 Numpy
10 |
11 | 🔸 pyautoui
12 |
13 | 🔸 OpenCV
14 |
15 | ## Installation
16 |
17 | Install my-project with npm
18 |
19 | ```bash
20 | pip install numpy
21 | ```
22 | ```bash
23 | pip install pyautogui
24 | ```
25 | ```bash
26 | pip install opencv-python
27 | ```
28 |
29 | ## Authors
30 |
31 | - [@TanmayProgrammer-13](github.com/TanmayProgrammer-13)
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/Screen Recorder Using Python/Screen Recorder Python.py:
--------------------------------------------------------------------------------
1 | #Screen Recorder Using Python
2 | # Importing Required Modules
3 | import pyautogui
4 | import cv2
5 | import numpy as np
6 |
7 | # Defining Resoultion Of the Screen Recorder
8 | resolution = (1920, 1080)
9 |
10 | # Specifying Codec
11 | codec = cv2.VideoWriter_fourcc(*"XVID")
12 |
13 | # Defining the OutPut File Name
14 | filename = "Screen-Recording.avi"
15 |
16 | # Defining the FPS of the Screen Recording
17 | fps = 60.0
18 |
19 |
20 | # Video Wrier Windows
21 | out = cv2.VideoWriter(filename, codec, fps, resolution)
22 |
23 | # Creating an Empty Windows
24 | cv2.namedWindow("Live", cv2.WINDOW_NORMAL)
25 |
26 | # Defining Live Screen Resoulution
27 | cv2.resizeWindow("Live", 480, 270)
28 |
29 | while True:
30 | # Taking ScreenShot Using pyautogui module
31 | img = pyautogui.screenshot()
32 |
33 | # Converting the ScreenShot to Numpy Array
34 | frame = np.array(img)
35 |
36 | # RGB
37 | frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
38 |
39 | # Defining OutPut File
40 | out.write(frame)
41 |
42 | #Displaying the Screen Recording
43 | cv2.imshow('Live', frame)
44 |
45 | #Stop Screen Recording When 'q' Is Pressed
46 | if cv2.waitKey(1) == ord('q'):
47 | break
48 |
49 | # Releaseing Video Writer
50 | out.release()
51 |
52 | # Destroy all windows
53 | cv2.destroyAllWindows()
--------------------------------------------------------------------------------
/ScreenShot Using Python.py:
--------------------------------------------------------------------------------
1 | #Take ScreenShot Using Python
2 | import pyscreenshot
3 |
4 | import pyscreenshot
5 |
6 | #Capture Full Screen
7 | image = pyscreenshot.grab()
8 |
9 | #Display The Captured ScreenShot
10 | image.show()
11 |
12 | #Save the Captured ScreenShot
13 | image.save("PyScreen1")
14 |
15 |
--------------------------------------------------------------------------------
/Simple Calculator.py:
--------------------------------------------------------------------------------
1 | #Calculator With Options
2 |
3 | a = int(input("Enter a Number: "))
4 | b = int(input("Enter another Number: "))
5 |
6 | op = input("Press The Desired Number Given: ")
7 |
8 | #Adding Options For Performing Actions
9 | print("Press 1 To Add")
10 | print("Press 2 To Subtract")
11 | print("Press 3 To Multiply")
12 | print("Press 4 To Divide")
13 | if op == "1":
14 | print("Result Of a+b Is: ",a+b)
15 | elif op == "2":
16 | print("Result Of a-b Is: ",a-b)
17 | elif op == "3":
18 | print("Result Of a*b Is: ",a*b)
19 | elif op == "4":
20 | print("Result Of a/b Is: ",a/b)
21 | else:
22 | print("Wrong Input Try Again...")
--------------------------------------------------------------------------------
/Snake Game Using Python/README.md:
--------------------------------------------------------------------------------
1 |
2 | # Snake Game Python
3 |
4 | Snake Game Using Python For Begginers
5 |
6 |
7 | ## Documentation
8 |
9 | Modules Used In This Project :-
10 |
11 | 1. Python Turtle
12 | 2. FreeGames Module #pip install freegames
13 | 3. Random Module
14 |
15 |
16 | ## Authors
17 |
18 | - [@TanmayProgrammer-13](https://github.com/TanmayProgrammer-13)
19 |
20 |
21 | ## Installation
22 |
23 | Install my-project with npm
24 |
25 | ```bash
26 | pip install freegames or
27 | $ python3 -m pip install freegames
28 | ```
29 |
30 | ## 🔗 Links
31 |
32 | [](https://twitter.com/MrProgrammer21)
33 |
34 |
--------------------------------------------------------------------------------
/Snake Game Using Python/game.py:
--------------------------------------------------------------------------------
1 | # Snake Game With Score Counter
2 | # Importing Required Modules
3 | from turtle import *
4 | from random import randrange
5 | import turtle
6 | from freegames import square, vector
7 |
8 |
9 | #Game Programming Starts Here
10 | #Setting Background Color
11 | bgcolor('black')
12 | #Defining Screen Resolution
13 | turtle.screensize('800 X 600')
14 | #Setting Game Title
15 | turtle.title("Snake Game")
16 |
17 | food = vector(0, 0)
18 | snake = [vector(10, 0)]
19 | aim = vector(0, -10)
20 |
21 | def change(x, y):
22 | aim.x = x
23 | aim.y = y
24 | def inside(head):
25 | return -200 < head.x < 190 and -200 < head.y < 190
26 | def move():
27 | head = snake[-1].copy()
28 | head.move(aim)
29 |
30 | if not inside(head) or head in snake:
31 | square(head.x, head.y, 9, 'Lime')
32 | update()
33 | return
34 |
35 | snake.append(head)
36 |
37 | if head == food:
38 | print('Snake:', len(snake))
39 | food.x = randrange(-15, 15) * 10
40 | food.y = randrange(-15, 15) * 10
41 | else:
42 | snake.pop(0)
43 |
44 | clear()
45 |
46 | for body in snake:
47 | square(body.x, body.y, 9, 'Lime')
48 |
49 | square(food.x, food.y, 9, 'red')
50 | update()
51 | ontimer(move, 100)
52 |
53 |
54 | hideturtle()
55 | tracer(False)
56 | listen()
57 | onkey(lambda: change(10, 0), 'Right')
58 | onkey(lambda: change(-10, 0), 'Left')
59 | onkey(lambda: change(0, 10), 'Up')
60 | onkey(lambda: change(0, -10), 'Down')
61 | move()
62 |
63 |
64 |
--------------------------------------------------------------------------------
/Text To HandWritten.py:
--------------------------------------------------------------------------------
1 | import pywhatkit
2 | pywhatkit.text_to_handwriting("Python Is High Level Progrmmming Language. It Is An Interpreted Language. Guido Van Rossum Created Python In 1991 When He Was Working At Centrum Wiskunde Of Informatica(CWI). Python Is a Case Senstive Language")
--------------------------------------------------------------------------------
/Text_To_Audio.py:
--------------------------------------------------------------------------------
1 | from gtts import gTTS
2 | import os
3 |
4 | #Enter The Text You Want To Be Converted In Audio
5 | Text_Enter = "Hello Everyone, This Program is Created By Mr Programmer In Python"
6 |
7 | #Enter the Language In Which You Want To Listen The Text
8 | Lang = 'en'
9 |
10 | #creating an object
11 | my_obj = gTTS(text=Text_Enter,lang=Lang,slow=False)
12 |
13 | #Converting Your Text File Into Audio(.mp3 ) Format
14 | my_obj.save("PyAudio.mp3")
15 | print("Audio Saved")
16 |
17 | os.system("PyAudio.mp3")
--------------------------------------------------------------------------------
/Web Scraper.py:
--------------------------------------------------------------------------------
1 | import requests
2 | from bs4 import BeautifulSoup
3 |
4 | req = requests.get("https://www.youtube.com/watch?v=O6nnVHPjcJU")
5 |
6 | soup = BeautifulSoup(req.content,"html.parser")
7 |
8 | res = soup.title
9 | print(res.prettify())
--------------------------------------------------------------------------------
/Web-Server/README.md:
--------------------------------------------------------------------------------
1 | # Web Server - Python 3
2 |
3 | ## What is a Web Server?
4 | A web server is computer software and underlying hardware that accepts requests via HTTP or its secure variant HTTPS.
5 |
6 | ## Prerequests for Server
7 |
8 | - HTTPServer
9 | - BaseHTTPRequestHandler
10 |
11 | ## Aurthor
12 | - [@TanmayProgrammer-13](https://github.com/TanmayProgrammer-13)
13 |
14 | ## Languages Used
15 | - Python 3
16 |
17 |
--------------------------------------------------------------------------------
/Web-Server/server.py:
--------------------------------------------------------------------------------
1 | # Basic Web Server In Python
2 | from http.server import BaseHTTPRequestHandler, HTTPServer
3 | import time
4 |
5 | hostName = "localhost"
6 | serverPort = 3000
7 |
8 | class MyServer(BaseHTTPRequestHandler):
9 | def do_GET(self):
10 | self.send_response(200)
11 | self.send_header("Content-type", "text/html")
12 | self.end_headers()
13 | self.wfile.write(bytes("Web Server - Python", "utf-8"))
14 | self.wfile.write(bytes("Request: %s
" % self.path, "utf-8"))
15 | self.wfile.write(bytes("", "utf-8"))
16 | self.wfile.write(bytes("This is a Web Server Hosted on a Local System
", "utf-8"))
17 | self.wfile.write(bytes("", "utf-8"))
18 |
19 | if __name__ == "__main__":
20 | webServer = HTTPServer((hostName, serverPort), MyServer)
21 | print("Server started http://%s:%s" % (hostName, serverPort))
22 |
23 | try:
24 | webServer.serve_forever()
25 | except KeyboardInterrupt:
26 | pass
27 |
28 | webServer.server_close()
29 | print("Server stopped.")
30 |
--------------------------------------------------------------------------------
/Week Number To Week Name Python:
--------------------------------------------------------------------------------
1 | #Week Number For Week Name
2 | a = input("Enter the Week Number: ")
3 | if a == "1":
4 | print("Monday")
5 | elif a == "2":
6 | print("Tuesday")
7 | elif a == "3":
8 | print("Wednesday")
9 | elif a == "4":
10 | print("Thursday")
11 | elif a == "5":
12 | print("Friday")
13 | elif a == "6":
14 | print("Saturday")
15 | elif a == "7":
16 | print("Sunday")
17 | else:
18 | print("Not a Valid Number!")
19 |
--------------------------------------------------------------------------------
/Whatsapp Automation Python.py:
--------------------------------------------------------------------------------
1 | import pywhatkit
2 |
3 | pywhatkit.sendwhatmsg("+919835061808","Hello Python Bot Here!",16,40)
--------------------------------------------------------------------------------
/YouTube Video Details Using Python/README.md:
--------------------------------------------------------------------------------
1 |
2 | # Get YouTube Video Details
3 | Get YouTube Video Details Using Python.
4 |
5 | ## Documentation
6 |
7 | Modules Used In This Project ➡
8 |
9 | 🔸 Pafy:- is library is used to retrieve YouTube content and metadata.
10 |
11 | ## Installation
12 |
13 | Required Modules To Install ➡
14 |
15 | ```bash
16 | pip install pafy
17 | ```
18 |
19 | ## Authors
20 |
21 | - [@TanmayProgrammer-13](Github.com/TanmayProgrammer-13)
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/YouTube Video Details Using Python/main.py:
--------------------------------------------------------------------------------
1 | #Get YouTube Video Details Using Python
2 | #Importing Required Modules
3 | import pafy
4 |
5 | #Taking The URL Of Video From User
6 | url = input("Enter the URL Of your Video Here: ")
7 |
8 | # Getting the Video
9 | video = pafy.new(url)
10 |
11 | # Getting Video Title
12 | print(video.title)
13 |
14 | # Getting Video Rating
15 | print(video.rating)
16 |
17 | # Getting Video Views Count
18 | print(video.viewcount)
19 |
20 | # Getting Aurthor & Video Length
21 | print(video.author,video.length)
22 |
23 | # Getting Video Duration, Likes , Dislikes & Description
24 | print(video.description,video.likes,video.dislikes,video.description)
25 |
--------------------------------------------------------------------------------
/annoy-friends.py:
--------------------------------------------------------------------------------
1 | import pyautogui
2 |
3 | while True:
4 | msgBox = pyautogui.confirm('Follow Mr Programmer')
5 | if msgBox == 'OK':
6 | break
--------------------------------------------------------------------------------
/audi.py:
--------------------------------------------------------------------------------
1 | # draw audi logo using python
2 | import turtle
3 | audi = turtle.Turtle()
4 |
5 | audi.pensize(7)
6 | turtle.Screen().bgcolor("black")
7 | audi.pencolor("#D0CFCF")
8 | audi.speed(10)
9 |
10 | #running for Loop
11 | for i in range(4):
12 | audi.penup()
13 | audi.goto(i*70, 0)
14 | audi.pendown()
15 | audi.circle(50)
16 |
17 |
18 | audi.color("white")
19 | audi.penup()
20 | audi.goto(77, -40)
21 | audi.pendown()
22 |
23 | audi.write("Audi By Mr Programmer",font=("Arial", 16, "bold","italic"))
24 | turtle.done()
25 |
--------------------------------------------------------------------------------
/dino.py:
--------------------------------------------------------------------------------
1 | import pyautogui
2 | from PIL import Image, ImageGrab
3 | import time
4 |
5 | def click(key):
6 | pyautogui.keyDown(key)
7 | return
8 |
9 | def isCollision(data):
10 |
11 | for i in range(530,560):
12 | for j in range(80, 127):
13 | if data[i, j] < 171:
14 | click("down")
15 | return
16 | for i in range(530, 620):
17 | for j in range(130, 160):
18 | if data[i, j] < 100:
19 | click("up")
20 | return
21 | return
22 |
23 | if __name__ == "__main__":
24 | time.sleep(5)
25 | click('up')
26 |
27 | while True:
28 | image = ImageGrab.grab().convert('L')
29 | data = image.load()
30 | isCollision(data)
31 |
32 |
--------------------------------------------------------------------------------
/jpg to png converter/README.md:
--------------------------------------------------------------------------------
1 | # Image Converter (JPG to PNG)
2 |
3 | Create Image Connverter Using Python Package Called Pillow
4 |
5 | ## Installation
6 |
7 | Install required-modules in cmd
8 |
9 | ```bash
10 | pip install Pillow
11 | ```
12 |
13 | ## Authors
14 |
15 | Follow Me On Github If you Like my Work:
16 |
17 | - [@TanmayProgrammer-13](https://github.com/TanmayProgrammer-13)
18 |
19 | ## About Aurthor
20 | I'm a web developer & Computer Programmer...
21 |
22 | ## 🔗 Links
23 | [](http://mrprogrammer.in/)
24 |
25 | [](https://twitter.com/MrProgrammer21)
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/jpg to png converter/src/converter/__init__.py:
--------------------------------------------------------------------------------
1 | # Modules Used
2 | from PIL import Image
--------------------------------------------------------------------------------
/jpg to png converter/src/converter/new_panda.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TanmayProgrammer-13/Python-Projects-For-Begginers/0aa646622550aa4d8f9ff0a780ecde989315ff72/jpg to png converter/src/converter/new_panda.png
--------------------------------------------------------------------------------
/jpg to png converter/src/converter/panda.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TanmayProgrammer-13/Python-Projects-For-Begginers/0aa646622550aa4d8f9ff0a780ecde989315ff72/jpg to png converter/src/converter/panda.jpg
--------------------------------------------------------------------------------
/jpg to png converter/src/converter/script.py:
--------------------------------------------------------------------------------
1 | # Importing Required Modules
2 | from PIL import Image
3 | # Define the Path Of Image where img is saved
4 | img = Image.open(r'C:\Users\tanma\Desktop\panda.jpg')
5 | img.save(r'C:\Users\tanma\Desktop\new_panda.png')
6 |
7 | # Giving Message to the User
8 | if img.save(r'C:\Users\tanma\Desktop\new_panda.png') == img.save(r'C:\Users\tanma\Desktop\new_panda.png'):
9 | print('Image Converted Sucessfully')
10 | # If Image Could Not Be Processed The Show the Message
11 | else:
12 | print('Image Could not Be Coverted \n Try Again')
--------------------------------------------------------------------------------
/main.py:
--------------------------------------------------------------------------------
1 | #Importing Modules
2 | import requests
3 | from bs4 import BeautifulSoup
4 |
5 | # Acessing HTML Page Or Website
6 | url = input('Enter the URL: ')
7 | r = requests.get(url)
8 |
9 | soup = BeautifulSoup(r.content,'html5lib')
10 | print(soup.prettify())
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/pubg-logo.py:
--------------------------------------------------------------------------------
1 | import turtle
2 |
3 | t = turtle.Turtle()
4 |
5 | turtle.bgcolor("black")
6 | t.color("white")
7 |
8 | def rect():
9 | t.pensize(9)
10 | t.forward(170)
11 | t.left(45)
12 | t.forward(6)
13 | t.left(45)
14 | t.forward(170)
15 | t.left(45)
16 | t.forward(6)
17 | t.left(45)
18 | t.forward(330)
19 | t.left(45)
20 | t.forward(6)
21 | t.left(45)
22 | t.forward(170)
23 | t.left(45)
24 | t.forward(6)
25 | t.left(45)
26 | t.forward(170)
27 |
28 | def four_corner_lines():
29 | t.pensize(12)
30 | t.penup()
31 | t.forward(180)
32 | t.left(90)
33 | t.forward(35)
34 | t.left(90)
35 | t.pendown()
36 | t.forward(12)
37 | t.penup()
38 | t.forward(344)
39 | t.pendown()
40 | t.forward(17)
41 | t.penup()
42 | t.right(90)
43 | t.forward(105)
44 | t.right(90)
45 | t.pendown()
46 | t.forward(17)
47 | t.penup()
48 | t.forward(344)
49 | t.pendown()
50 | t.forward(12)
51 |
52 | def p():
53 | t.penup()
54 | t.left(180)
55 | t.forward(280)
56 | t.pendown()
57 | t.forward(40)
58 | t.left(90)
59 | t.forward(100)
60 | t.left(180)
61 | t.forward(52)
62 | t.right(90)
63 | t.forward(40)
64 | t.left(90)
65 | t.forward(47)
66 |
67 | def u():
68 | t.penup()
69 | t.right(90)
70 | t.forward(32)
71 | t.right(90)
72 | t.pendown()
73 | t.forward(98)
74 | t.left(90)
75 | t.forward(40)
76 | t.left(90)
77 | t.forward(98)
78 |
79 | def b():
80 | t.penup()
81 | t.right(90)
82 | t.forward(35)
83 | t.pendown()
84 | t.forward(45)
85 | t.right(90)
86 | t.forward(43)
87 | t.right(45)
88 | t.forward(5)
89 | t.right(45)
90 | t.forward(40)
91 | t.left(90)
92 | t.forward(5)
93 | t.left(90)
94 | t.forward(40)
95 | t.right(45)
96 | t.forward(5)
97 | t.right(45)
98 | t.forward(40)
99 | t.right(90)
100 | t.forward(45)
101 | t.right(90)
102 | t.forward(96)
103 |
104 | def g():
105 | t.penup()
106 | t.right(180)
107 | t.forward(53)
108 | t.left(90)
109 | t.forward(98)
110 | t.pendown()
111 | t.forward(25)
112 | t.right(90)
113 | t.forward(45)
114 | t.right(90)
115 | t.forward(45)
116 | t.right(90)
117 | t.forward(95)
118 | t.right(90)
119 | t.forward(40)
120 |
121 | rect()
122 | four_corner_lines()
123 | p()
124 | u()
125 | b()
126 | g()
127 |
128 | turtle.done()
--------------------------------------------------------------------------------
/snake,water gun python.py:
--------------------------------------------------------------------------------
1 | # Import random module
2 | import random
3 |
4 | print('Snake - Water - Gun')
5 |
6 | # Input no. of rounds
7 | n = int(input('Enter number of rounds: '))
8 |
9 | # List containing Snake(s), Water(w), Gun(g)
10 | options = ['s', 'w', 'g']
11 |
12 | # Round numbers
13 | rounds = 1
14 |
15 | # Count of computer wins
16 | comp_win = 0
17 |
18 | # Count of player wins
19 | user_win = 0
20 |
21 | # There will be n rounds of game
22 | while rounds <= n:
23 |
24 | # Display round
25 | print(f"Round :{rounds}\nSnake - 's'\nWater - 'w'\nGun - 'g'")
26 |
27 | # Exception handling
28 | try:
29 | player = input("Chose your option: ")
30 | except EOFError as e:
31 | print(e)
32 |
33 | # Control of bad inputs
34 | if player != 's' and player != 'w' and player != 'g':
35 | print("Invalid input, try again\n")
36 | continue
37 |
38 |
39 | computer = random.choice(options)
40 |
41 | # Conditions based on the game rule
42 | if computer == 's':
43 | if player == 'w':
44 | comp_win += 1
45 | elif player == 'g':
46 | user_win += 1
47 |
48 | elif computer == 'w':
49 | if player == 'g':
50 | comp_win += 1
51 | elif player == 's':
52 | user_win += 1
53 |
54 | elif computer == 'g':
55 | if player == 's':
56 | comp_win += 1
57 | elif player == 'w':
58 | user_win += 1
59 |
60 | # Announce winner of every round
61 | if user_win > comp_win:
62 | print(f"You Won round {rounds}\n")
63 | elif comp_win > user_win:
64 | print(f"Computer Won round {rounds}\n")
65 | else:
66 | print("Draw!!\n")
67 |
68 | rounds += 1
69 |
70 |
71 | if user_win > comp_win:
72 | print("Congratulations!! You Won")
73 | elif comp_win > user_win:
74 | print("You lose!!")
75 | else:
76 | print("Match Draw!!")
--------------------------------------------------------------------------------
/turtle-design.py:
--------------------------------------------------------------------------------
1 | import turtle
2 | # Creating turtle
3 | t = turtle.Turtle()
4 |
5 | turtle.bgcolor("black")
6 | turtle.pensize(2)
7 | turtle.speed(0)
8 |
9 | while (True):
10 | for i in range(6):
11 | for colors in ["red", "blue", "magenta", "green", "yellow", "white"]:
12 | turtle.color(colors)
13 | turtle.circle(100)
14 | turtle.left(10)
15 |
16 |
17 | turtle.hideturtle()
18 | turtle.mainloop()
--------------------------------------------------------------------------------