Python Exercises
Python Exercises
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.
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?
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.
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?