Python Module 2 - AFV. Funda-1
Python Module 2 - AFV. Funda-1
Pytho
n
“” #
Python
()
Agenda
( ) #
Python uses
● Single-line indentation to ● Empty
● Multi-line indicate a block of ● Simple
● Docstring ● Compound
code.
COMMENT
wHY DO WE USE
COMMENTS#
Pytho
n
Computer ignores any text
“‘ # written after the hash.
’”
# # ‘‘‘’’’
# ●
●
Starts with a hash symbol (#)
#
Can write comments of multiple lines using
hash at the beginning of each line.
Example
# THIS IS A MULTILINE
# COMMENT IN PYTHON
# USING THE SINGLE LINE
# COMMENT CONSECUTIVELY
COMMENT
Doc string
‘‘‘’’’
● Comment spans within multiple lines.
● Ignores everything in quotation marks.
“““””” ●
●
Written using 3 signal or 3 double quotes.
This is called Doc strings.
Example
“““You can write docstring like this”””
‘‘‘You can also write docstring like this’’’
COMMENT
When to use
comment?
● Programming is often done by teams of people
Importance of INDENTATION
INDENTATIOn ERROR
Indentation
wHAT IS
INDENTATION?
● Indentation refers to the spaces at the
INDENTATION
beginning of a code line. ERROR
● Whitespace is used for indentation in
Python.
● Python uses indentation to highlight the
blocks of code.
● All statements with the same distance to
the right belong to the same block of
code.
Indentation
Look at the
meme
All statements with the same distance to
the right belong to the same block of
code.
If a block has to be more deeply nested,
it is simply indented further to the right.
Indentation
Example
Program
Indentation
Example
For
statement
If statement
LMS Assignment
Primary Data Type
.py .txt
Numbers Strings
Data Type
True/False
Boolean
Numbers
What are
Numbers
What are
statements?
What is a
variable?
height =1.79
weight = 68.7
bmi = weight / height * height
print(bmi)
LMS Assignment
Identifiers
What are
identifiers?
Assign multiple
Simple Assignment values to multiple
variables
Example Example
a=100 a, b = 100, 200
print(a) print(a)
100 100
print(b)
200
Types of Assignments
Categories of keywords
Built-in
Description Code Output
Function
Returns absolute value of a
abs() number
abs(-11) Answer: 11
Raises a number to a
pow() power
pow(10, 2) Answer: 100