First python program.

 


Here is the first Python program most beginners start with — the classic Hello, World! program.

✅ First Python Program

print("Hello, World!")

👉 How to run it:

If you are using a computer:

  1. Open IDLE or VS Code or any editor.
  2. Create a new file → save it as first.py
  3. Type the code:
    print("Hello, World!")
    
  4. Run the file:
    • In IDLE: Press F5
    • In VS Code: Click Run ▶
    • In Terminal:
      python first.py
      

If you want to run directly online:

You can search “Python online compiler” and paste the code.


Want a slightly advanced first program?

Here is one that takes user input:

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

Sure! Here are more beginner-friendly Python programs, each one teaching an important concept.


✅ 1. Print Multiple Lines

print("Welcome to Python!")
print("This is your first program.")
print("Let's learn step by step.")

✅ 2. Taking User Input

name = input("Enter your name: ")
age = input("Enter your age: ")
print("Hello", name, "! You are", age, "years old.")

✅ 3. Simple Calculator

a = int(input("Enter first number: "))
b = int(input("Enter second number: "))

print("Sum =", a + b)
print("Difference =", a - b)
print("Product =", a * b)
print("Quotient =", a / b)

✅ 4. Check Even or Odd

num = int(input("Enter a number: "))

if num % 2 == 0:
    print(num, "is Even")
else:
    print(num, "is Odd")

✅ 5. Find Largest of Two Numbers

a = int(input("Enter first number: "))
b = int(input("Enter second number: "))

if a > b:
    print(a, "is larger")
else:
    print(b, "is larger")

✅ 6. Loop Example (1 to 10)

for i in range(1, 11):
    print(i)

✅ 7. Sum of Numbers Using Loop

total = 0
for i in range(1, 6):
    total += i

print("Sum =", total)

✅ 8. List Example

fruits = ["apple", "banana", "mango"]

for fruit in fruits:
    print(fruit)

✅ 9. Function Example

def greet():
    print("Hello from a function!")

greet()

✅ 10. Function With Parameters

def add(a, b):
    return a + b

result = add(5, 7)
print("Sum =", result)

If you want, I can also give you:

  • 20 more small Python programs
  • A beginner practice sheet
  • Python MCQs
  • A full Python notes PDF



Post a Comment

0 Comments