Skip to content

Commit 816403f

Browse files
author
Manuraj Singh Rathore
authored
simple calculator (#32)
* calculator * manuraj16 * calculator * pdfconverter * pdftotext * pdftotext * passwordgenerator * passwordgenerator * rockpaperscissor * Update rockpaperscissor_manuraj16.py * Create rockpaperscissor_manuraj16.py
1 parent 08ce4b5 commit 816403f

File tree

4 files changed

+108
-0
lines changed

4 files changed

+108
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import random
2+
3+
you = input("your turn: Scissor(s) , Rock(r) or Paper(p)?")
4+
print (f"you chose {you}")
5+
6+
print("comp turn : Scissor(s) , Rock(r) or Paper(p) ?")
7+
randNo = random.randint(1,3)
8+
if randNo == 1 :
9+
comp = "s"
10+
elif randNo == 2 :
11+
comp = "r"
12+
elif randNo == 3 :
13+
comp = "p"
14+
15+
print (f"computer chose {comp}")
16+
17+
if comp=="s" :
18+
if you=="s" :
19+
print ('tie')
20+
if you=="p" :
21+
print ('you lose')
22+
if you=="r" :
23+
print ('you win')
24+
elif comp=="r" :
25+
if you=="p" :
26+
print ('you win')
27+
if you=="r" :
28+
print ('tie')
29+
if you=="s" :
30+
print ('you loose')
31+
elif comp=="p" :
32+
if you=="r" :
33+
print ('you loose')
34+
if you=="s" :
35+
print ('you win')
36+
if you=="p" :
37+
print ('tie')

clculator_manuraj16.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# simple claculator
2+
3+
print("select operation :-")
4+
print("(1) add")
5+
print("(2) subtract")
6+
print("(3) multiply")
7+
print("(4) divide")
8+
9+
def add(x,y) :
10+
return x+y
11+
def subtract(x,y) :
12+
return x-y
13+
def multiply(x,y) :
14+
return x*y
15+
def divide(x,y) :
16+
return x/y
17+
18+
choice = int(input("choose from 1,2,3,4 : "))
19+
num1 = float(input("Enter 1st number : "))
20+
num2 = float(input("Enter 2nd number : "))
21+
22+
if choice == 1 :
23+
print (f"{num1} + {num2} = ", add(num1,num2))
24+
elif choice == 2:
25+
print (f"{num1} - {num2} = ", subtract(num1,num2))
26+
elif choice == 3:
27+
print (f"{num1} * {num2} = ", multiply(num1,num2))
28+
elif choice == 4:
29+
print (f"{num1} / {num2} = ", divide(num1,num2))
30+
else :
31+
print ("invalid entry")
32+

passwordgenerator_manuraj16.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#Random password generator
2+
3+
import string
4+
import random
5+
6+
s1 = string.ascii_uppercase
7+
s2 = string.ascii_lowercase
8+
s3 = string.digits
9+
s4 = string.punctuation
10+
11+
len = int(input("Enter hte legnth of password "))
12+
13+
s = []
14+
s.extend(list(s1))
15+
s.extend(list(s2))
16+
s.extend(list(s3))
17+
s.extend(list(s4))
18+
19+
random.shuffle(s)
20+
print ("Your password is :")
21+
print ("".join(s[:len]))

pdftotext_manuraj16.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import PyPDF2
2+
3+
pdfpath = input("Enter the name of your pdf file - please use backslash when typing in directory path: ")
4+
txtpath = input("Enter the name of your txt file - please use backslash when typing in directory path: ")
5+
6+
pdfobj = open(pdfpath, 'rb')
7+
8+
pdfread = PyPDF2.PdfFileReader(pdfobj)
9+
y = pdfread.getNumPages()
10+
11+
str = ""
12+
for i in range(1,y) :
13+
str += pdfread.getPage(i).extractText()
14+
15+
with open(txtpath, 'w', encoding = "utf-8") as f:
16+
f.write(str)
17+
18+
print(str)

0 commit comments

Comments
 (0)