Python Projects (Advance)

1. Timer

import time
num=int(input('Enter Seconds '))
dog=1
while num>1:
time.sleep(1)
print(dog,'seconds')
dog=dog+1
num=num-1
time.sleep(1)
print(dog,'seconds , Time up!')


2. Typing Test

import time
print('THIS IS A TYPING TEST HERE YOU WLL WRITE THE SAME THING AS IT IS WRITTEN BELLOW WITH SAME SPACE BAR AND SAME INDENTION')
print('WRITE a s d...........\nas it is shown below')

a= str(input('a s d f j k l ;\n'))
b='a s d f j k l ;'
while a!=b:
print('incorrect')
a=str(input('TRY AGAIN\n'))
print('correct\n')
time.sleep(2)

qq='a s d f g h j k l ;'
ww=str(input('a s d f g h j k l ;\n'))
while qq!=ww:
print('incorrect')
ww=str(input('TRY AGAIN\n'))
print(qq)
print('correct')

3. Maths Game

import time
print('hello it is a math solver here you can do some maths problems\n')
time.sleep(3)
print('what do you want to take out these are the given list\n1. AREA AND PERIMETER OF SQUARE\n2. SIMPLE INTREST\n3. PRIME CHECKER\n4. AREA AND PERIMETER OF RECTANGLE\n5. ARMSTRONG NUMBER CHECKER\n')
time.sleep(3)
print('enter 1 for first option and 2,3 respectively')

moon=int(input('what do you want to take out in the given list :\n'))
if moon==1:
x=input('What do you want to find area or perimeter of the square \n' )
if x=='area':
y=int(input('Enter side of the square \n' ))
z=y*y
elif x=='perimeter':
t=int(input('enter side of the square \n' ))
z=t*4
print('YOUR ANSWER IS :',z)

if moon==2:
p=int(input('Enter Principle '))
r=int(input('enter rate '))
t=int(input('enter time '))
qq=p*r*t/100
print('YOUR ANSWER IS :',qq)

if moon ==3:
def is_prime(num):
for i in range(2,num):
if (num%i==0):
return False
return True
num=int(input('enter a number\n'))
check_prime=is_prime(num)
if check_prime:
print('ANS: Yes it is a prime number')
else:
print('ANS: No it is not a prime number')

if moon==4:
q=input('What do you want to find area or perimeter of the rectangle \n' )
if q=='area':
w=int(input('Enter length of the rectangle \n' ))
e=int(input('Enter breadth of the rectangle \n' ))
z=w*e
elif q=='perimeter':
qw=int(input('Enter length of the rectangle \n' ))
uv=int(input('Enter breadth of the rectangle \n' ))
z=qw*uv
print('YOUR ANSWER IS :',z)

if moon ==5:
n=input('enter a number to check it for a armstrong number ')
a=0
d=0
for num in n:
a=int(num)
d=d+a**3
a=a+1
if d==int(n):
print(f'Yes {n} is an armstrong number.')
else:
print(n,'is not a armstrong number.')

4. Stone, Paper, Scissor

Game

score=0
comp_score=0
print('stone = s \npaper = p\nscissor = sr')
while True:
import random
import time

user=input('Enter your choice ')
comp=random.randint(0,2)

if user =='quit':
print('Total Score :',score)
break
elif comp ==0:
comp='stone'
if user=='s':
print('YOU : stone')
print('COMPUTER :',comp)
time.sleep(2)
print('***Match Tie***')
print('-----------------------------------------')
time.sleep(2)
print('Comp Score :', comp_score)
print('YOUR SCORE :',score)

elif user=='p':
print('YOU : paper')
print('COMPUTER :',comp)
time.sleep(2)
print('***You Win***')
time.sleep(2)
print('---------------------------------------')
print('Comp Score :', comp_score)
score=score+10
print('YOUR SCORE :',score)

elif user=='sr':
print('YOU : scissor')
print('COMPUTER :',comp)
time.sleep(2)
print('**Comp Win***')
time.sleep(2)
print('---------------------------------------')
comp_score=comp_score+10
print('Comp Score :',comp_score)
print('YOUR SCORE :',score)
print('---------------------------------------')

elif comp ==1:
comp='paper'
if user=='p':
print('YOU : paper')
print('COMPUTER :',comp)
time.sleep(2)
print('***Match Tie***')
print('-----------------------------------------')
time.sleep(2)
print('Comp Score :', comp_score)
print('YOUR SCORE :', score)

elif user=='sr':
print('YOU : scissor')
print('COMPUTER :',comp)
time.sleep(2)
print('***You Win***')
time.sleep(2)
print('---------------------------------------')
score=score+10
print('Comp Score :', comp_score)
print('YOUR SCORE :',score)

elif user=='s':
print('YOU : stone')
print('COMPUTER :',comp)
time.sleep(2)
print('***Comp Win***')
time.sleep(2)
print('---------------------------------------')
comp_score = comp_score + 10
print('Comp Score :', comp_score)
print('YOUR SCORE :',score)
print('---------------------------------------')

elif comp ==2:
comp='scissor'
if user=='sr':
print('YOU : scissor')
print('COMPUTER :',comp)
time.sleep(2)
print('***Match Tie***')
print('-----------------------------------------')
time.sleep(2)
print('Comp Score :', comp_score)
print('YOUR SCORE :',score)

elif user=='s':
print('YOU : stone')
print('COMPUTER :',comp)
time.sleep(2)
print('***You Win***')
time.sleep(2)
print('---------------------------------------')
print('Comp Score :', comp_score)
score=score+10
print('YOUR SCORE :',score)

elif user=='p':
print('YOU : paper')
print('COMPUTER :',comp)
time.sleep(2)
print('**Comp Win***')
time.sleep(2)
print('---------------------------------------')
comp_score = comp_score + 10
print('Comp Score :', comp_score)
print('YOUR SCORE :',score)
print('---------------------------------------')

5. Dairy Writing

For doing this you should have another empty file named file2.txt.

print('Enter quit to exit')
print('enter read to see file2.txt')
while True:
aa = input('Write what do you want to write in your dairy \n')
if aa=='quit':
break

if aa == 'read':
f = open('file2.txt')
content = f.read()
print(content)

else:
with open('file2.txt','a') as f:
import datetime

now = datetime.datetime.now()
x=now.strftime("\nDATE : %Y-%m-%d\n")

f.write(f'{x}')
f.write(f'{aa}\n')

6. Calculator

while True:
print('If you want to stop the calculation type quit \n ')
o = input('Enter your Operator [* / + - ] \n')

if o =='quit':
break

f_n = float(input('Enter First Number\n'))
s_n = float(input('Enter second Number\n'))

ans='invalid'

if o == '+':
ans=f_n+s_n
if o =='-':
ans=f_n-s_n
if o =='*':
ans=f_n*s_n
if o =='/':
ans=f_n/s_n


print(f'Your ans is {ans}\n')
print('-------------------------------------------------------------------------------------------------')

Comments

Popular posts from this blog

Python Projects (GUI)

GUI Lessons (full course) with codes.

Turtle Graphics (full Course) with codes