Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Tutorial 2: Introduction to Python Programming

Introduction

Python is a popular programming language known for its simplicity and readability. In this
tutorial, we will cover the basics of Python programming.

Step-by-Step Guide

1. Set Up Your Environment


o Install Python from python.org.
o Install a text editor like Visual Studio Code or an IDE like PyCharm.
2. Write Your First Python Program
o Create a new file named hello.py and add the following code:

python
Copy code
print("Hello, world!")

3. Run Your Program


o Open a terminal or command prompt, navigate to the folder containing
hello.py, and run the following command:

Copy code
python hello.py

4. Basic Python Syntax


o Variables and Data Types:

python
Copy code
x = 5
y = "Hello"
z = 3.14

o Control Structures:

python
Copy code
if x > 0:
print("x is positive")
else:
print("x is not positive")

o Loops:

python
Copy code
for i in range(5):
print(i)

5. Functions
o Define and call a function:
python
Copy code
def greet(name):
return f"Hello, {name}"

print(greet("Alice"))

You might also like