Python Unit1
Python Unit1
Python Unit1
Python Programming
Module: 1
Preface
shaping the future. The topics covered in this course are not just
chapter at a time.
Learning Objectives:
environment.
expressions.
Structure:
1.4 Operators
1.6 Loops
1.7 Functions
1.8 Summary
1.9 Keywords
1.12 Reference
beginners.
Guido van Rossum began working on Python in the late 1980s and
Python language.
more.
modification.
vast community.
execution:
● Script Mode: You write your Python code in a file (with a .py
python filename.py.
programming.
To use Jupyter Notebook, one must first install it. Given its
Python and R.
Anaconda for your OS. This will install both Python and
Jupyter Notebook.
directory.
● Files Tab: This tab shows the list of files and folders in the
current directory.
notebooks.
a new folder.
Checkpoint.
benefits:
understandable.
in a broader context.
● Integers
and negative.
● Example: -3, 0, 42
● Floats
● Strings
""") quotes.
● Booleans
● Type Conversion
conversions.
● Type Checking
type of a value.
● Usage:
1.4 Operators
operators in Python :
1. Arithmetic Operators:
calculations.
operator. E.g., a + b.
side. E.g., a * b.
E.g., a ** b.
2. Comparison Operators:
3. Logical Operators:
statement is true.
is false.
4. Assignment Operators:
operand. E.g., a = b.
equivalent to a = a + b.
above.
5. Bitwise Operators:
● Used for performing operations on bits.
● |: Bitwise OR.
● ~: Bitwise NOT.
right.
sequence.
memory location.
a. Lists
changed).
● Key properties:
value.
b. Tuples
● Key properties:
● Allows duplicates.
c. Sets
unique_numbers = {1, 2, 3, 4, 4, 5}
● Key properties:
● Mutable: You can add and remove items from the set.
d. Dictionary
pair form.
● Key properties:
can repeat.
1.6 Loops
The for loop in Python is used to iterate over sequences (like lists,
tuples, strings, or ranges). With this loop, one can execute a set of
● Basic Syntax:
● Examples:
Unlike the for loop which operates over a sequence, the while
loop keeps executing its body as long as its condition remains true.
● Basic Syntax:
● Example:
● Example:
● Example:
● Example:
1.7 Functions
advantages:
redundancy.
parameters.
and 4 is for y.
to parameters.
value 25
the lambda keyword. They can have multiple inputs but only one
expression.
respectively.
These are just a few examples; Python has a rich set of built-in
1.8 Summary
human-readable code.
method.
❖ Symbols that perform arithmetic, comparison, logical,
data efficiently.
1.9Keywords
any parameters.
Python?
in Python: ^, **, or %?
5. How can you access the values of a dictionary using its keys?
Introduction:
Background:
Enter Maya, a final year BCA student with a flair for Python
development process.
Maya used the pandas library to handle, analyse, and visualise the
products. For the GUI, she employed tkinter, making the system
based solution not only addressed the immediate pain points but
Questions:
2. How did the use of Python and its libraries assist in creating
1.12 References
by Brett Slatkin