Tutorial 3: Your First Python Program
How to Create Your First Python Program (Hello World and User Input)
Topics Covered
- Opening the Python Interpreter
-
Creating a
.pyfile - Running a Python program
-
Using the
print()function -
Using the
input()function - Displaying output on the screen
Example 1: Hello World
print("Hello World")
Output:
Hello World
Example 2: Displaying a Name
name = "John"
print("My name is", name)
Output:
My name is John
Example 3: Getting Input from the Keyboard
name = input("Enter your name: ")
print("Hello", name)
Output:
Enter your name: David
Hello David
Example 4: Simple Addition
a = 10
b = 20
c = a + b
print("Result =", c)
Output:
Result = 30
Suggested Next Tutorials
Tutorial 4: Python Variables and Data Types
Topics:
- String
- Integer
- Float
- Boolean
Example:
name = "John"
age = 25
height = 175.5
is_active = True
Tutorial 5: Python Operators
Topics:
-
Addition (
+) -
Subtraction (
-) -
Multiplication (
*) -
Division (
/) -
Modulus (
%) -
Exponent (
**)
Example:
print(10 + 5)
print(10 - 5)
print(10 * 5)
print(10 / 5)
Tutorial 6: Python IF-ELSE Statements
Example:
age = 18
if age >= 18:
print("You are allowed to vote.")
else:
print("You are not allowed to vote yet.")
Tutorial 7: Python FOR and WHILE Loops
Example:
for i in range(1, 6):
print(i)
Output:
1
2
3
4
5
Tutorial 8: Building a Simple Calculator
Example:
a = int(input("First number: "))
b = int(input("Second number: "))
print("Result =", a + b)
Tutorial 9: Number Guessing Game
A beginner-friendly project that introduces programming logic and user interaction.
Tutorial 10: Simple Contact Book
This project introduces:
- Lists
- Dictionaries
- Functions
Recommended Learning Path for Complete Beginners
- Install Python
- Your First Python Program
- Variables and Data Types
- Input and Output
- Operators
- IF-ELSE Statements
- FOR Loops
- WHILE Loops
- Functions
- Lists
- Dictionaries
- Mini Projects
This learning sequence helps beginners gradually build confidence and practical coding skills while avoiding information overload.
Baca versi Indonesia: Klik Di sini

No comments:
Post a Comment