Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 83b148a

Browse files
added programs👩‍💻👩‍💻
1 parent 6369be4 commit 83b148a

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Python program to shuffle a deck of card
2+
3+
# importing modules
4+
import itertools, random
5+
6+
# make a deck of cards
7+
deck = list(itertools.product(range(1,14),['Spade','Heart','Diamond','Club']))
8+
9+
# shuffle the cards
10+
random.shuffle(deck)
11+
12+
# draw five cards
13+
print("You got:")
14+
for i in range(5):
15+
print(deck[i][0], "of", deck[i][1])
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Program make a simple calculator
2+
3+
# This function adds two numbers
4+
def add(x, y):
5+
return x + y
6+
7+
# This function subtracts two numbers
8+
def subtract(x, y):
9+
return x - y
10+
11+
# This function multiplies two numbers
12+
def multiply(x, y):
13+
return x * y
14+
15+
# This function divides two numbers
16+
def divide(x, y):
17+
return x / y
18+
19+
20+
print("Select operation.")
21+
print("1.Add")
22+
print("2.Subtract")
23+
print("3.Multiply")
24+
print("4.Divide")
25+
26+
while True:
27+
# Take input from the user
28+
choice = input("Enter choice(1/2/3/4): ")
29+
30+
# Check if choice is one of the four options
31+
if choice in ('1', '2', '3', '4'):
32+
num1 = float(input("Enter first number: "))
33+
num2 = float(input("Enter second number: "))
34+
35+
if choice == '1':
36+
print(num1, "+", num2, "=", add(num1, num2))
37+
38+
elif choice == '2':
39+
print(num1, "-", num2, "=", subtract(num1, num2))
40+
41+
elif choice == '3':
42+
print(num1, "*", num2, "=", multiply(num1, num2))
43+
44+
elif choice == '4':
45+
print(num1, "/", num2, "=", divide(num1, num2))
46+
break
47+
else:
48+
print("Invalid Input")

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /