TGViewer
Data Science & Machine Learning Data Science & Machine Learning @datasciencefun ยท 77.8K subscribers
Post #4423 2.87K
๐Ÿš€ Data Science Roadmap 2026

๐Ÿ“˜ Phase 1: Programming Fundamentals

๐Ÿ Topic 3: Python Input & Output

In the previous lesson, you learned about Python Operators. Now it's time to learn how Python interacts with users by taking input and displaying output.

Input and Output (I/O) are fundamental concepts because almost every real-world program accepts input, processes it, and produces meaningful output.

๐Ÿ”น 1. What is Input & Output?

A Python program generally follows three steps:

Input โ†’ Process โ†’ Output

Example:

โ€ข User enters two numbers Input

โ€ข Python adds them Process

โ€ข Sum is displayed Output

๐Ÿ”น 2. Displaying Output

Python uses the print() function to display information on the screen.

Example

print("Hello, Data Science!")


Output

Hello, Data Science!


๐Ÿ”น 3. Printing Variables

You can print variables along with text.

name = "Deepak"
print(name)


Output:

Deepak


Or:

name = "Deepak"
print("Welcome", name)


Output:

Welcome Deepak


๐Ÿ”น 4. Taking User Input

Python uses the input() function to receive input from users.

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


Example Output:

Enter your name: Deepak
Hello Deepak


๐Ÿ”น 5. Important Note โญ

The input() function always returns a string, even if the user enters a number.

age = input("Enter age: ")
print(type(age))


Output:

<class 'str'>


๐Ÿ”น 6. Converting Input to Integer

To perform mathematical operations, convert the input using int().

age = int(input("Enter your age: "))
print(age + 5)


Example:

Enter your age: 25
30


๐Ÿ”น 7. Taking Decimal Input

Use float() for decimal numbers.

price = float(input("Enter price: "))
print(price)


๐Ÿ”น 8. Taking Multiple Inputs

You can take multiple inputs in a single line.

name, city = input("Enter your name and city: ").split()
print(name)
print(city)


Example Input:

Deepak Mumbai


Output:

Deepak
Mumbai


๐Ÿ”น 9. Formatting Output

Using f-Strings โญ Recommended

name = "Deepak"
age = 25
print(f"My name is {name} and I am {age} years old.")


Output:

My name is Deepak and I am 25 years old.


Using .format()

name = "Deepak"
print("Welcome {}".format(name))


๐Ÿ”น 10. Example Program

name = input("Enter your name: ")
age = int(input("Enter your age: "))

print(f"Hello {name}")
print(f"Next year you will be {age + 1} years old.")


Example Output:

Enter your name: Deepak
Enter your age: 25
Hello Deepak
Next year you will be 26 years old.


๐Ÿ”น 11. Common Mistake

num1 = input("Enter first number: ")
num2 = input("Enter second number: ")
print(num1 + num2)


Input:

10
20


Output:

1020


Why?

Because both values are strings.

Correct way:
  • โค 6
More from @datasciencefun
  1. Oct 8, 2026๐Ÿ”ฌ Kandinsky 6.0 Video: Training Details and Architecture The new Kandinsky 6.0 Video lineโ€ฆ
  2. Oct 8, 2026๐ŸŽ“ ๐— ๐—ถ๐—ฐ๐—ฟ๐—ผ๐˜€๐—ผ๐—ณ๐˜ ๐—™๐—ฅ๐—˜๐—˜ ๐—–๐—ผ๐˜‚๐—ฟ๐˜€๐—ฒ๐˜€ ๐˜„๐—ถ๐˜๐—ต ๐—–๐—ฒ๐—ฟ๐˜๐—ถ๐—ณ๐—ถ๐—ฐ๐—ฎ๐˜๐—ฒ๐˜€! ๐Ÿš€๐Ÿ”ฅ Upgrโ€ฆ
  3. Oct 7, 2026ORDER BY salary DESC LIMIT 5; Mistake 3 โ€” Forgetting that LIMIT applies after sorting Forโ€ฆ
  4. Oct 7, 2026๐Ÿš€ Data Science Roadmap 2026 ๐Ÿ“ Phase 3: SQL for Data Science ๐Ÿ“– Topic 4 โ€” LIMIT LIMIT isโ€ฆ
  5. Oct 7, 2026๐Ÿš€๐—ฃ๐—ฎ๐˜† ๐—”๐—ณ๐˜๐—ฒ๐—ฟ ๐—ฃ๐—น๐—ฎ๐—ฐ๐—ฒ๐—บ๐—ฒ๐—ป๐˜ ๐—ง๐—ฟ๐—ฎ๐—ถ๐—ป๐—ถ๐—ป๐—ด | ๐—•๐—ฒ๐—ฐ๐—ผ๐—บ๐—ฒ ๐—ฎ ๐—™๐˜‚๐—น๐—น๐˜€๐˜๐—ฎ๐—ฐโ€ฆ
  6. Oct 7, 2026๐— ๐—ฎ๐˜€๐˜๐—ฒ๐—ฟ ๐—ฃ๐—ผ๐˜„๐—ฒ๐—ฟ ๐—•๐—œ ๐—ณ๐—ผ๐—ฟ ๐—™๐—ฅ๐—˜๐—˜! ๐Ÿ”ฅ Learn Power BI through these FREE learninโ€ฆ
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook โ†’Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 โ†’