Skip to content

Commit 4ffad8c

Browse files
upload question 2
1 parent e94f0d0 commit 4ffad8c

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

test/question-2.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
'''
2+
question-2.py - Michael Bateman
3+
Python Coding Bat Test - ICS3U
4+
Feb 16/17
5+
'''
6+
7+
# imports - none
8+
9+
# functions
10+
11+
def sortaSum(int_a, int_b): # this creates a function called 'sortaSum' that can recieve data
12+
totalsum = int_a + int_b # this creates the sum stored in a variable called 'totalsum'
13+
if ((10 <= totalsum <= 19) == True): # this checks to see if the total sum is between 10 and 19 (inclusive).
14+
return 20 # if it is between 10 and 19, it just returns 20
15+
else:
16+
return totalsum # if it is not between 10 and 19 it returns to real sum
17+
18+
# user input
19+
20+
int_a = input("Please enter your first number: ") # here, the user will input a number that is stored in 'int_a'
21+
int_b = input("Please enter your second number: ") # then, a second number is asked and it is stored in 'int_b'
22+
# both 'int_a' and 'int_b' data types are int's
23+
24+
# raw code
25+
26+
print(sortaSum(int_a, int_b)) # prints what is returned in in the 'sortaSum' function

0 commit comments

Comments
 (0)