Professional Documents
Culture Documents
Unit 2 - Data Types and String - Lec (1) - 1
Unit 2 - Data Types and String - Lec (1) - 1
Unit 2 - Data Types and String - Lec (1) - 1
COMMENTS
• Helps in getting description about the code for future reference.
• Python comment starts with # symbol
• E.g. #compute the percentage of the hour that has elapsed percentage.
• Percentage = (minute * 100)/60
UNIT II: DATA TYPES AND STRINGS
BY : CJCENTENO
BY : CJCENTENO
Image: https://morioh.com/p/b51aa797cb94
Python docstrings are the string literals that appear right •The declaration happens automatically when you
assign a value to a variable.
after the definition of a function, method, class, or
• Variables can have any name, but Python reserved
module. words cannot be used.
BY : CJCENTENO BY : CJCENTENO
*Note: You cannot use reserved words for variable names and identifiers.
BY : CJCENTENO BY : CJCENTENO
1
10/13/2020
MULTIPLE
ASSIGNING VALUES TO VARIABLES
ASSIGNMENT
• Python allows you to assign a
single value to several variables
simultaneously.
a=b=c=1
a, b, c = 1, 2, "cris“
https://w w w .netclipart.com/isee/ioxoxo_person-thinking-clipart-emoticon-smiley-face-emoji-clipart/
BY : CJCENTENO BY : CJCENTENO
DATA TYPES
It is a classification that
specifies which type of
value a variable has and
what type of
mathematical, relational https://threatpost.com/zoom-removes-data-mining-linkedin-feature/154404/
BY : CJCENTENO BY : CJCENTENO
del var1
del var_a, var_b
BY : CJCENTENO BY : CJCENTENO
2
10/13/2020
STRING IS A SEQUENCE OF
CHARACTERS, LIKE "PYTHON IS COOL"
• Each character has an index
x = "Python is cool“
print(x[10])
BY : CJCENTENO BY : CJCENTENO
STRING
• It is a sequence of characters.
• It may contain alphabets, numbers and special characters.
• Usually strings are enclosed within a single quotes and double quotes.
BY : CJCENTENO BY : CJCENTENO
4. TUPLE
3. LIST • Tuple is an ordered sequence of items same as a list. The only difference is that
tuples are immutable. Tuples once created cannot be modified.
• List is an ordered sequence of items. It is one of the most used datatype in Python
and is very flexible. All the items in a list do not need to be of the same type.
BY : CJCENTENO BY : CJCENTENO
3
10/13/2020
BY : CJCENTENO BY : CJCENTENO
BOOLEAN VALUES
Booleans represent one of two values: True or False.
END OF UNIT ii
BY : CJCENTENO BY : CJCENTENO