User input program | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

User input program

Hie I'm new to Python (to programming in fact).Can you please help me on how to create a program that requires the user to enter (inputs function ) two integers and multiple them

31st Jul 2017, 11:34 PM
Leboman HKD Galis
Leboman HKD Galis - avatar
2 Answers
+ 4
num1=int(input("Enter a number: ")) num2=int(input("Enter another number: ")) print(num1*num2) Let's break it down. The first line is creating a variable to store the first number. by default input() is a string. Since we want integers, we wrap the input inside of int(). This lets python know that num1 is in fact an integer. The next line repeats this process to store a second number as num2. The third line prints the output of num1 multiplied by num2
31st Jul 2017, 11:58 PM
LordHill
LordHill - avatar
+ 1
Thanks, be blessed
1st Aug 2017, 6:26 AM
Leboman HKD Galis
Leboman HKD Galis - avatar