Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions Calculator.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
def addition():
print("Addition")
n = float(input("Enter the number: "))
t = 0 //Total number enter
t = 0 #Total number enter
ans = 0
while n != 0:
ans = ans + n
Expand All @@ -12,7 +12,7 @@ def addition():
def subtraction ():
print("Subtraction");
n = float(input("Enter the number: "))
t = 0 //Total number enter
t = 0 #Total number enter
sum = 0
while n != 0:
ans = ans - n
Expand All @@ -23,7 +23,7 @@ def subtraction ():
def multiplication ():
print("Multiplication")
n = float(input("Enter the number: "))
t = 0 //Total number enter
t = 0 #Total number enter
ans = 1
while n != 0:
ans = ans * n
Expand All @@ -39,6 +39,12 @@ def average():
ans = a / t
return [ans,t]

#def squareit(n):
# squaredlist = []
# res = n**2
# squaredlist.append(res)
# return squaredlist[0]

while True:
list = []
print(" My first python program!")
Expand All @@ -47,6 +53,7 @@ def average():
print(" Enter 's' for substraction")
print(" Enter 'm' for multiplication")
print(" Enter 'v' for average")
#print(" Enter 'sqr' for square of a number")
print(" Enter 'q' for quit")
c = input(" ")
if c != 'q':
Expand All @@ -62,6 +69,10 @@ def average():
elif c == 'v':
list = average()
print("Ans = ", list[0], " total inputs ",list[1])
# elif c == 'sqr':
# n = float(input(enter a number you wish to square))
# list = squareit()
# print("Ans = ", list[0], " total inputs ",list[n])
else:
print ("Sorry, invilid character")
else:
Expand Down