Skip to content

Commit 524c776

Browse files
authored
Add files via upload
0 parents  commit 524c776

File tree

3 files changed

+84
-0
lines changed

3 files changed

+84
-0
lines changed

Diff for: calculator.py

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
print("_________________Welcome to calculator !_________________ ")
2+
3+
#Assigment operators used to simply assign data.
4+
a = int (input ("Enter first number: ") )
5+
b = int (input ("Enther secound number: "))
6+
choice = int (input ("Enter the calculation you want to perform 1 for Addition, 2 for substraction, 3 for multiplication and 4 for division "))
7+
8+
9+
#logical operator used to check if condition.
10+
if choice <= 4:
11+
#Arthematic operators used for calculations.
12+
def case1 ():
13+
print (a+b)
14+
def case2 ():
15+
print (a-b)
16+
def case3 ():
17+
print (a*b)
18+
def case4 ():
19+
print (a/b)
20+
21+
def switch_case(case):
22+
#comparision operators to check conditions.
23+
if(case == 1):
24+
case1()
25+
elif(case == 2):
26+
case2()
27+
elif(case == 3):
28+
case3()
29+
elif(case == 4):
30+
case4()
31+
32+
switch_case(choice)
33+
34+
35+
36+
else:
37+
print ("Enter number between 1 to 5... Please! ")

Diff for: diamond.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Diamond Pattern
2+
3+
x = int (input ("Enter number of rows: "))
4+
5+
for i in range (1, x+1):
6+
for j in range (1, x - i + 1):
7+
print (" ", end = " ")
8+
9+
for j in range (1, 2 * i):
10+
print("*", end = " ")
11+
12+
print()
13+
14+
for i in range (x - 1, 0, -1):
15+
for j in range (1, x - i + 1):
16+
print (" ", end = " ")
17+
18+
for j in range (1, 2 * i):
19+
print ("*", end = " ")
20+
21+
print()
22+
23+

Diff for: diamond_border.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Diamond Boder Pattern
2+
3+
x = int (input ("Enter number of rows: "))
4+
5+
for i in range (1, x + 1):
6+
for j in range (1, x - i + 1):
7+
print (" ", end = " ")
8+
9+
for j in range (1, 2 * i):
10+
if j == 1 or j == 2 * i - 1:
11+
print ("*", end = " ")
12+
else:
13+
print (" ", end = " ")
14+
print()
15+
16+
for i in range (x - 1, 0, -1):
17+
for j in range (1, x - i + 1):
18+
print (" ", end = " ")
19+
for j in range (1, 2 * i):
20+
if j == 1 or j == 2 * i - 1:
21+
print ("*", end = " ")
22+
else:
23+
print (" ", end = " ")
24+
print()

0 commit comments

Comments
 (0)