Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
20 views2 pages

Python Exercises

This document presents a set of Python exercises to review basic programming concepts such as data types, mathematical operations, functions, lists, tuples, and dictionaries. The student must complete the 16 questions by providing Python code and explanations, and share the document with their teacher for feedback and corrections.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views2 pages

Python Exercises

This document presents a set of Python exercises to review basic programming concepts such as data types, mathematical operations, functions, lists, tuples, and dictionaries. The student must complete the 16 questions by providing Python code and explanations, and share the document with their teacher for feedback and corrections.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

INFORMATION TECHNOLOGY COURSE: 1st YEAR OF BACHILLERATO

Python (Exercises)
Objective
It is about reviewing all the programming concepts in Python necessary for
to move on to the next phase of development. Some of the elements that you will encounter
In this questionnaire, you may have already used them in your practices, others not. Remember that the
Inspiration does not come passively, so turn to all sources of information.
Whatever you need; books, wiki, teacher... In any case, good luck and good work.

Procedure
This file should have arrived to you by email. If you are working in pairs, it should have arrived to both of you.
but you can do it together:
• Create a text document in Google Docs and copy into it the questions you find.
you will bring it down. Alternatively, do it in an Open Office document and upload it to
Google Docs.
• Share it (only) with your teacher so they can track your progress and correct it.
when you finish it (menu 'Share' -> 'Invite users' and write their email;
make sure it is checked 'For editing')
• Answer each question by writing the answers immediately below.
Do it in blue so that it stands out easily. Write all the code with
I am monitoring all the bleeding with fidelity that, as you know, are so important in
Python. Add all the explanations you need.
• When you have finished, rename the file and add the word 'Completed' (menu
Rename...

Exercises
1. Escribe un ejemplo de cada tipo de dato que conoces de Python (es decir, un entero,
a decimal, a string...) indicating each type with its Pythonic name.

2. Convierte el entero 3 en un float y en una string. ¿Cómo convertirías el texto 'hola' en


a list? What do you get?

3. Calcula el resto y el cociente de la división entera entre 3.2 y 1.1

4. Investigate: When you write 3.5 in the interpreter, it returns 3.5. But when it is-
describes 3.6 what do you get? Why? As you can imagine, in the operations
most common numerical values do not have much influence, but if extremely high calculations are desired
Precision can be remedied. How?
INFORMATION TECHNOLOGY 1st BACH

5. You can easily convert a list into a tuple and vice versa. But what is the difference?
Is there any between them? Can you provide an example to illustrate it?

6. Given the list [3,-2,5,7,0,1.5], extract the sublist [5,7,0] with a Python instruction.
Add the number 3.14. Remove the 7.

7. Given the tuple (3,6,9,10, 17) extract the subtuple (3,9,17) with a python instruction.
Would you know how to obtain the inverted tuple?

8. Write a function that, given a word, returns the first letter.

9. Write a function that, given a word, says whether it starts with a capital letter (that is,
return True in that case and False otherwise.

10. Write a function that, given a text, returns the number of words it contains.

11. Write a function that, given a text, writes it reversed.

12. Write a function that returns a list with the squares of the numbers from 1 to
10.

13. Now it is about doing the above in a different way. Would you know how to do it in a single line?
of code using list comprehensions?

14. And what if you are asked, instead of the squares, for the cubes of the odd numbers between 1
and 10?

15. Write a function that, given a text, determines if it is an email address.


valid (that is, it should return True if it is something of the [email protected] False in
otherwise).

The provided text seems to be incomplete.


function that, given a name, returns its phone number. Write another function
that given a phone number, it says to whom it belongs. Of course, in both ca-
SOS, if the program does not exist, it should not give an error but kindly say -
Gather all this into a program that allows its user to use the dictionary or
stop doing it, at your choice.

You might also like