Week 1&3 Python Programming
Week 1&3 Python Programming
Python is widely used in various domains such as web development, data science,
machine learning, and more.
It has a large and active community, making it easy to find support and
resources.
Visit the official Python website to download and install the latest version of
Python.
3.2 Choose a Text Editor or IDE (Integrated Development Environment)
Options include Visual Studio Code, PyCharm, Jupyter Notebooks, or simple text
editors like Atom or Sublime Text.
pythonCopy code
# my_first_program.py print ( "Hello, World!" )
Open a terminal or command prompt, navigate to the directory where you saved
the file, and type python my_first_program.py.
You should see the output: Hello, World!.
Engage with the Python community through forums, social media, and local
meetups.
This step-by-step guide should give you a solid foundation for understanding the basics
of computer science and programming with Python. Good luck on your learning
journey!
Week 2
STEP 1: EXPLORING DATA TYPES
1.1 INTEGER ( INT)
Represents whole numbers without decimals.
Example: x = 5
1.2 FLOAT (FLOAT)
Represents numbers with decimals.
Example: y = 3.14
1.3 STRING (STR)
Represents textual data enclosed in single or double quotes.
Example: name = 'John'
1.4 BOOLEAN ( BOOL)
Represents True or False values.
Example: is_python_fun = True
4.2 LITERALS
Directly used in your code.
Numeric literals: 42, 3.14
String literals: 'hello', "world"
EXAMPLE CODE:
# Exploring Data Types
integer_var = 42
float_var = 3.14
string_var = 'Hello, World!'
boolean_var = True
# Displaying Results
print("Integer Variable:", integer_var)
print("Float Variable:", float_var)
print("String Variable:", string_var)
print("Boolean Variable:", boolean_var)
print("Age:", age)
print("Name:", name)
print("Is Student?", is_student)
ADDITIONAL TIPS:
Comments: Use # for comments in your code to explain complex parts or provide context.
Interactive Mode: Python has an interactive mode where you can type code directly into the
interpreter to experiment and learn.
This guide should help you understand and practice working with Python data types, variables, type
casting, and constants. Feel free to experiment with the examples and modify the code to deepen
your understanding.
Week 3
LAB 1: DATA TYPES AND VARIABLES LAB
STEP 1: SET UP YOUR PYTHON ENVIRONMENT
1.1. Make sure Python is installed on your computer. If not, you can download it from
the official Python website.
1.2. Choose a text editor or integrated development environment (IDE) for writing your
Python code. Options include Visual Studio Code, PyCharm, or Jupyter Notebooks.
2.2. Create a new Python file with a meaningful name, like data_types_lab.py.
Integer: age = 25
Float: height = 5.9
String: name = 'Alice'
Boolean: is_student = True
STEP 4: PERFORM OPERATIONS AND TYPE CASTING
4.1. Perform operations on variables:
age_in_two_years = age + 2
updated_height = height * 2
full_name = name + ' Smith'
age_str = str(age)
height_int = int(height)
is_student_str = str(is_student)
6.4. Run your Python program using the command python data_types_lab.py.
7.2. Verify that the calculated values and type castings are correct.
ADDITIONAL TIPS:
Experiment with different values and operations to deepen your understanding.
Add comments to your code explaining each section.
If you encounter errors, use the error messages to troubleshoot and correct your code.
This lab should provide hands-on experience with data types, variables, operations, and
type casting in Python. Feel free to modify and expand the exercises to enhance your
learning.