Course Module
Course Module
Control flow statements are used to make decisions and repeat tasks based on
conditions. They help the program flow dynamically rather than linearly.
These are essential to solve logical problems and build interactive applications.
Control flow statements dictate the order of execution in a Python program. Key
constructs include:
• break and continue: Alters loop execution (break exits, continue skips to
the next iteration).
Department of Computer Applications
Department of Computer Applications
grade = "A"
grade = "B"
grade = "C"
grade = "D"
else:
grade = "F"
count = 5
print(count)
Learning Outcome:
Students will understand how to control the logic of the program, implement
conditions and loops, and solve decision-based problems.
Department of Computer Applications
Python provides four fundamental built-in data structures: lists, tuples, sets,
and dictionaries. Each has unique characteristics and is suited for different
purposes.
Learning Outcome:
Students will understand how to store, access, and manage data using Python’s
built-in data structures such as lists, tuples, sets, and dictionaries, and apply the
appropriate structure based on the nature of the problem.
Department of Computer Applications
Key Concepts:
print(f"Hello, {name}!")
Output:
Hello, Siva!
File: math_operations.py
return a + b
return a - b
Importing a Module
import math_operations
sum_result = math_operations.add(5, 3)
diff_result = math_operations.subtract(5,
3)
print(sum_result)
print(diff_result)
Department of Computer Applications
Learning Outcome:
Students will understand how to define and use functions to avoid repetitive
code, and how to organize large programs using modules and libraries. This
helps in building clean, readable, and modular Python programs.
Department of Computer Applications
Python provides built-in functions to create, read, write, and update files.
File handling is essential for storing data permanently and interacting with text,
binary, and CSV files.
Mode Description
'b' Binary mode – Used for binary files (e.g., images, audio)
Example
# Writing to a file
file.write("Hello, Python!")
content = file.read()
print(content)
TEXT BOOKS: