ðĻðŦ 4K | Microsoft Visual Studio 2022 - Python Tutorial for Beginners - How to Create Multiplication Table based on User Input.
Python Source Code by iBasskung.
print('Python Program to Generate Multiplication Table Demo by iBasskung.\n')
# Python While Loop
# To take input from the user
while True:
# Python Exception Handling
try:
# Input upto the table number starting from 1
n1 = int(input("Enter the first number: "))
if(n1 <= 0):
print('Must be a number greater than 0.\n')
continue
n2 = int(input("Enter the second number: "))
if(n2 <= 0):
print('\nInvalid input: The first and second numbers must be greater than 0.\n')
continue
else:
break
except ValueError:
print('\nPlease input integer only...\n')
continue
print('\nMultiplication table from 1 to ' + str(n1) + "\n")
# Increment variables value by 1.
n1 += 1
n2 = n2 + 1
# Python Nested for loop.
# outer loop
for a in range(1, n1):
print(a, 'Tables.')
# inner loop
for b in range(1, n2):
# result
c = a * b
print(str(a),'x','{:2d}'.format(b),'=','{:2d}'.format(c))
print()
print('Thank you very much for watching.\n')
print('Please like and subscribe to my channel.\n')
#END
ðŊ See more:
ðē YouTube: https://www.youtube.com/c/iBasskung
ðē Facebook: https://www.facebook.com/CodeAMinute
ðē Udemy: https://www.udemy.com/user/tanin-sangngam
ðē SkillLane: https://www.skilllane.com/instructors/iBasskung
ðŊ THANK YOU SO MUCH ðŊ
#Python #WhileLoop #ForLoop #MultiplicationTable #VisualStudio2022 #iBasskung #ComputerProgramming
Python Tutorial for Beginners - How to Create Multiplication Table based on User Input
ReplyDeleteVery interesting post...
Learn About The Importance Of Dot Net Development
.net development services