forked from lechuzalibre/python-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultiplicationtable.py
More file actions
32 lines (28 loc) · 1.1 KB
/
Copy pathmultiplicationtable.py
File metadata and controls
32 lines (28 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
'''Create a multiplication table application where user will enter a sentinel value n and the application will display the mathematical multiplication tables till given sentinel value n.'''
# Importing the required modules
import sys
# Defining the main function
def main():
'''This is the main function'''
# Getting the user input
sentinel_value = input('Enter the sentinel value: ')
# Calling the function to get the result
result = multiplication_table(sentinel_value)
# Printing the result
print(result)
# Defining the function to get the multiplication table
def multiplication_table(sentinel_value):
'''This function gets the multiplication table'''
# Converting the sentinel value to int
sentinel_value = int(sentinel_value)
# Getting the multiplication table
for number in range(1, sentinel_value + 1):
for multiplier in range(1, 11):
result = number * multiplier
print(number, 'x', multiplier, '=', result)
print('')
# Returning the result
return result
# Calling the main function
if __name__ == '__main__':
main()