0% found this document useful (0 votes)
10 views

Translated Presentation Part1

Uploaded by

kawtarmahassine2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Translated Presentation Part1

Uploaded by

kawtarmahassine2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Advanced Computing

• Table of Contents

• 2

• Data Types (continued):


• Booleans
• Tuples
• Sets
• Dictionaries
Data Types Used in Python
• What are the data types used in Python?

• 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

• Strings are immutable sequences of characters.


• A list is an ordered collection of data that can be characters, integers, or even
another list (called a nested list).
• Single and double quotes are used for defined strings.
• A list is mutable/modifiable.
• Strings can be indexed.
• Lists are declared with brackets.

• Lists allow duplicate elements.


• Lists can be created using the list() function.
• Lists can be indexed.
Function: join()
• Join() is a built-in string function in Python used to join elements
of a sequence separated by a string separator. This function
joins elements of an iterable sequence and creates a string
without quotes.

• 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

You might also like