Important Notice:

Input and Output Programs

Input and Output Programs

2 views 1 min read

Input and Output Program :-

Example:-1

# Input from the user
name = input("Enter your name: ")

# Output to the screen
print("Hello,", name)
 
Output-
Enter your name: Alice
Hello, Alice
 
Input Two Numbers and Print Their Sum :-
 
Example 2 -
 
# Input
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))

# Process
sum = num1 + num2

# Output
print("The sum is:", sum)
 
Output -
Enter first number: 10
Enter second number: 20
The sum is: 30
 

Related Notes