Translated Presentation Part1
Translated Presentation Part1
• Table of Contents
• 2
• BOOLEANS
• Booleans are built-in Python data types used to determine if an action
is successful or not using preassigned commands True or False, which
are essentially just the integers 1 and 0 with customized display logic.
• If you want to define a boolean in Python, you can simply assign a
value True or False or even an expression that ultimately corresponds
to one of these values. You can check the type of the variable using
the built-in type function in Python.
Booleans
• True and False behave exactly like the integers 1 and 0
except they have customized printing logic - they print
themselves as the words True and False.
• True and False are special values that belong to the bool
type (which are not strings):
Strings and Lists
• Strings
• Lists
• Syntax: string_name.join(iterable)
• Parameters:
• Iterable: a set of objects capable of returning their elements
one by one, e.g., Lists, Tuple, String, Dictionary, and Set.
• Return Value: The join() method returns a concatenated string
with the elements of iterable.
Exercise
• Create two lists that you define. Concatenate
the elements of the two lists into one. Display
the elements of the list as strings. Calculate
the length of the two lists.
Exercise
• Assign the variables time and distance with
the values 6.892 and 19.7. Calculate and
display the speed value.
Exercise
Exercise
• Consider the following string: word = ‘Python’.
What is the length of the string from ‘y’?
• If we want to get the string ‘loco’ from ‘cool’,
what is the procedure to follow?
• Create a string by multiplying ‘ri’ three times
and adding ‘du’ twice.
• Calculate the sum of elements from 0 to 65.
exercice