Week 1
Introduction to Computer Science and Python Basics
Step 1: Understanding the Role of Computer Science in Modern
Technology
1.1 What is Computer Science?
Computer Science is the study of computers and computing concepts.
It involves understanding algorithms, data structures, and the principles that
govern the design of computer systems.
1.2 Role in Modern Technology
Computer Science plays a crucial role in the development of technology.
It's the foundation for software development, artificial intelligence, data science,
and more.
Step 2: Introduction to Python Programming
2.1 What is Python?
Python is a high-level, versatile programming language.
It's known for its readability and simplicity, making it an excellent language for
beginners.
2.2 Why Python?
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.
Step 3: Setting Up a Python Development Environment
3.1 Install Python
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.
3.3 Verify Installation
Open a terminal or command prompt and type python --version to ensure
Python is installed correctly.
Step 4: Writing and Running Your First Python Program
4.1 Open a Text Editor
Open your chosen text editor or IDE.
4.2 Write a Simple Python Program
pythonCopy code
# my_first_program.py print ( "Hello, World!" )
4.3 Save the File
Save the file with a .py extension, for example, my_first_program.py.
4.4 Run the Program
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!.
Step 5: Further Learning
5.1 Online Resources
Explore online tutorials, documentation, and interactive platforms like
Codecademy, Coursera, or edX for more in-depth learning.
5.2 Practice and Projects
Practice regularly by solving coding challenges on platforms like HackerRank or
LeetCode.
Start simple projects to apply your knowledge and gain practical experience.
5.3 Join the Community
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
STEP 2: DECLARING AND INITIALIZING VARIABLES
2.1 VARIABLE DECLARATION
Variables are containers for storing data.
Example: age
2.2 INITIALIZING VARIABLES
Assign values to variables using the = operator.
Example: age = 25
STEP 3: TYPE CASTING AND CONVERSIONS
3.1 TYPE CASTING
Convert one data type to another.
Example: float_age = float(age)
3.2 TYPE CONVERSIONS
Use functions like int(), float(), str() for explicit conversions.
Example: num_str = "123", num_int = int(num_str)
STEP 4: WORKING WITH CONSTANTS AND LITERALS
4.1 CONSTANTS
Variables whose values should not change.
Convention: Uppercase variable names.
Example: PI = 3.14159
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
# Declaring and Initializing Variables
age = 25
name = 'John'
is_student = False
# Type Casting and Conversions
float_age = float(age)
num_str = "123"
num_int = int(num_str)
# Working with Constants and Literals
PI = 3.14159
GREETING = 'Welcome'
# 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)
print("Float Age:", float_age)
print("Numeric String as Integer:", num_int)
print("PI Constant:", PI)
print("Greeting Literal:", GREETING)
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.
STEP 2: CREATE A NEW PYTHON FILE
2.1. Open your chosen text editor or IDE.
2.2. Create a new Python file with a meaningful name, like data_types_lab.py.
STEP 3: DEFINE VARIABLES AND DATA TYPES
3.1. Declare and initialize variables for different data types:
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'
4.2. Use type casting to convert variables:
age_str = str(age)
height_int = int(height)
is_student_str = str(is_student)
STEP 5: DISPLAY RESULTS
5.1. Use the print function to display the results:
print("Current Age:", age)
print("Age in Two Years:", age_in_two_years)
print("Updated Height:", updated_height)
print("Full Name:", full_name)
print("Is Student?", is_student)
5.2. Display type-casted variables:
print("Age as String:", age_str)
print("Height as Integer:", height_int)
print("Is Student as String:", is_student_str)
STEP 6: RUN YOUR PYTHON PROGRAM
6.1. Save your Python file.
6.2. Open a terminal or command prompt.
6.3. Navigate to the directory where your Python file is located.
6.4. Run your Python program using the command python data_types_lab.py.
STEP 7: ANALYZE THE OUTPUT
7.1. Review the output in the terminal to ensure your program runs without errors.
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.
Lab2 studend = lab2@cusl
!*
Lab tech = lab2@cusl!!