INTERACTIVE ONLINE COURSE

Python 3

FOR BEGINNERS


"The first Python course that simply amazed me. Very well explained and easy to understand." (Alexandru Cosmin)

"The best Python course in Romania." (Iulian Geană)


ALL REVIEWS
EXERCISES
PAGE 1 / 1
Tuples, Sets and Dictionaries
Home >>> Online Lessons, Python 3

Proposed Problems

Tuples
a) Create a tuple with 5 favorite colors and display it.
b) Combine two tuples containing integers and display the result.
c) Find the largest and smallest element in a tuple of integers.
d) Declare a tuple of integers and display it in reverse order.


Sets
a) Create two sets of integers and find the intersection between them (common elements).
b) Check if a specific element exists in a set of characters.
c) Remove duplicate elements from a set.
d) Unite two sets and display the resulting set.


Dictionaries
a) Create a dictionary with the names and grades of 5 students and display it.
b) Display the number of elements in a dictionary.
c) Display the key with the highest value in a dictionary of integers.
d) Create a dictionary with the names and ages of 4 friends. Then, add a new key-value pair for another friend.

Mini-project - Library **



In a library, information about the favorite books of different readers is stored. Each reader is represented by their name and a list of favorite books. Create a data structure to store this information and solve the following requirements:

a) Add 5 different readers to the library, along with their favorite books.
b) Find all the books that are read by at least two readers and display them.
c) Determine how many different books are read in total by all the readers.
d) Find the name of the reader who reads the most books and display their number.

Hints. Create a code sequence for each requirement. Solving this problem requires the use of a combination of tuples, sets, and dictionaries to store and organize information about readers and their favorite books. By solving this project, you will use several different concepts and be able to interconnect various data structures in a slightly more complex project.

Mini-project - Friends Group **



A group of friends wants to organize periodic meetings in various locations. Each meeting is represented by a tuple containing the date, location, and the names of the participants. Create a data structure to manage these meetings and solve the following requirements:

a) Add 3 meetings to the data structure, each with the date, location, and list of participants.
b) Find all unique locations where meetings have been organized.
c) Determine how many friends have participated in total at the meetings and display the number.
d) Find all the meetings a specific friend has attended and display them.

Hints. This small project gives you the opportunity to familiarize yourself with how to use tuples to represent meeting information, sets to find unique locations, and dictionaries to organize and access participants at each meeting.
Editor - proposed_ex.py
       
Console/Output done
USER FRIENDLY

In any field you work in, or if you are a student, your programs should read and display information easily, with helpful hints and informative messages.

Behind the scenes, in the code, is your program – the processing! But the user of the program needs ONLY elegant and suggestive inputs and outputs.

So, pay attention to the information you request, how you present it, and what you communicate!
 home   list  CONTENTS   perm_identity   arrow_upward