Welcome to the world of Python programming. Python is a versatile and beginner-friendly language that's widely used for various applications. Let's explore some basic Python code examples.
Example 1: Hello, World!
The classic "Hello, World!" program:
print("Hello, World!")
When you run this code, it will display "Hello, World!" on your screen. It's often the first program beginners write.
Example 2: Calculate the Sum
A program that calculates the sum of two numbers:
# Define two numbers
num1 = 5
num2 = 7
# Calculate the sum
sum = num1 + num2
# Display the result
print(f"The sum of {num1} and {num2} is {sum}")