Python Mastery – From Basics to Brilliance / Python Fundamentals

Input & Output Operations

📤 Output in Python

We use the print() function to display something on the screen.

print("Welcome to Python!") #Welcome to Python!

You can print multiple items using commas:

name='abc'
age=10
print("Name:", name, "Age:", age) #Name: abc , Age : 10

📥 Input in Python

To take user input, use the input() function. It always returns a string.

name = input("What is your name? ")
print("Hello,", name) 
# What is your name? Codeveda
# Hello, Codeveda

❗ Important: Always cast input to the desired type if you’re doing calculations.

product = input("Enter product name: ")
price = float(input("Enter price: "))
qty = int(input("Enter quantity: "))
print(f"Bill: {product} x {qty} = Rs.{price*qty}")