Skip to content

Commit 86207dc

Browse files
authored
Upendra14 (#34)
* calculator * passwordgenerator * powercontroller * simplecalculator * passwordgenerator * rockpaperscissorgame
1 parent 94ccd33 commit 86207dc

6 files changed

+139
-0
lines changed

Rock,paper,scissor_game-upendra.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import random
2+
3+
def gameWin(player1, player2):
4+
5+
if player1 == player2:
6+
return None
7+
8+
elif player1 == 'P':
9+
if player2=='R':
10+
return False
11+
elif player2=='S':
12+
return True
13+
14+
elif player1 == 'R':
15+
if player2=='S':
16+
return False
17+
elif player2=='P':
18+
return True
19+
20+
elif player1 == 'S':
21+
if player2=='P':
22+
return False
23+
elif player2=='R':
24+
return True
25+
26+
print("player1 Turn: Paper(P) Rock(R) or Scissor(S)?")
27+
randNo = random.randint(1, 3)
28+
if randNo == 1:
29+
player1 = 'P'
30+
elif randNo == 2:
31+
player1 = 'R'
32+
elif randNo == 3:
33+
player1 = 'S'
34+
35+
player2 = input("Your Turn: Paper(P) Rock(R) or Scissor(S)?")
36+
a = gameWin(player1,player2)
37+
38+
print(f"Computer chose {player1}")
39+
print(f"You chose {player2}")
40+
41+
if a == None:
42+
print("The game is a TIE!")
43+
elif a:
44+
print("You Win!")
45+
else:
46+
print("You Lose!")

calculator-upendra.py

Whitespace-only changes.

passwordGen-upendra.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import string
2+
import random
3+
4+
pslen=int(input("Enter your password length"))
5+
6+
LCC = string.ascii_lowercase
7+
UCC = string.ascii_uppercase
8+
Digits = string.digits
9+
Symbols = string.punctuation
10+
11+
Total = UCC + LCC + Symbols + Digits
12+
13+
temp=random.sample(Total,pslen)
14+
password = "".join(temp)
15+
16+
print(password)

passwordgenerator-upendra.py

Whitespace-only changes.

power_control-upendra.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import os
2+
3+
print("1. Shutdown your Computer after Given Time")
4+
print("2. Restart your Computer after Given Time")
5+
print("3. Exit")
6+
7+
print(end="Enter Choice: ")
8+
choice = int(input())
9+
10+
if choice==1:
11+
print(end="Enter Number of Seconds: ")
12+
sec = int(input())
13+
str1 = "shutdown /s /t "
14+
str2 = str(sec)
15+
str = str1+str2
16+
os.system(str)
17+
18+
elif choice==2:
19+
print(end="Enter Number of Seconds: ")
20+
sec = int(input())
21+
str1 = "shutdown /r /t "
22+
str2 = str(sec)
23+
str = str1+str2
24+
os.system(str)
25+
elif choice==3:
26+
exit()
27+
else:
28+
print("Invalid!")
29+
30+
31+
32+
33+
34+
35+

simple_calculator-upendra.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
a=float(input("Enter 1st number"))
2+
b=float(input("Enter 2nd number"))
3+
4+
def divide(a,b):
5+
result=a/b
6+
print(result)
7+
8+
def multiply(a,b):
9+
result=a*b
10+
print(result)
11+
12+
def sum(a,b):
13+
result=a+b
14+
print(result)
15+
16+
def subtract(a,b):
17+
result=a-b
18+
print(result)
19+
20+
print("Select operation.")
21+
print("1.sum")
22+
print("2.Subtract")
23+
print("3.Multiply")
24+
print("4.Divide")
25+
op =int(input("Enter the operator"))
26+
if op ==1:
27+
sum(a,b)
28+
elif op ==2:
29+
subtract(a,b)
30+
elif op ==3:
31+
multiply(a,b)
32+
elif op ==4:
33+
divide(a,b)
34+
else:
35+
print("invalid")
36+
37+
38+
39+
40+
41+
42+

0 commit comments

Comments
 (0)