PYTHON Tutorial



INPUT & OUTPUT IN PYTHON


📥 Python Input and 📤 Output

In Python, you can interact with users using the input() function for input and the print() function for output.

🔸 Taking Input

The input() function reads a line from user input as a string:

name = input("Enter your name: ")
print("Hello, " + name + "!")
  

🔢 Converting Input Type

Use int(), float(), or bool() to convert string input:

age = int(input("Enter your age: "))
print("You will be", age + 1, "next year.")
  

🔸 Output with print()

The print() function displays data on the screen:

print("Welcome to Technorank!")
print("Python", "is", "fun", sep=" - ")
print("Loading...", end=" Done!\n")
  

✨ Print Formatting

You can use f-strings for clean output:

name = "Amit"
score = 95
print(f"{name} scored {score} marks.")
  
💡 Tip: Always convert user input to the desired type before using it in calculations.

🌟 Enjoyed Learning with Us?

Help others discover Technorank Learning by sharing your honest experience.
Your support inspires us to keep building!

Leave a Google Review