Python Exam 2 Bat
Python Exam 2 Bat
- --------------------------------------------------------------------------------------------
Name and Surname ………………………………………
Course: ………………………………………
- --------------------------------------------------------------------------------------------
Python Exam
Test
Multiple choice questions penalize ⅓ of the value of the questions.
7
b) 3
c) 1
d) 2
a) True
b) False
c) 5
d) 8
6. What value should x have for the program to print 'option c'?
x = ?
if x < 5:
option a
elif x == 5:
option b
else
print 'option c'
a) 5
b) 4
9
-1
1/5
IES Sorolla
a) True
b) False
'H'
'u'
c) It would generate an error
Python exam
Exam phenot
'nhy eaE'
It would generate an error
and Python
Python
Python
d) It would generate an error
2/5
IES Sorolla
a) 0
b) 2
c) 4
d) 6
a) ['alumno1','alumno2','alumno3']
b) ['alumno10','alumno2','alumno3']
c) ['alumno1','alumno10','alumno3']
d) ['alumno1','alumno2','alumno10']
17. Given the following list, very_list = ["you", "coffee", "sugar", "saccharin"]. Write the
Python statement that prints the value 'sugar' to the console
3/5
Sorolla High School
18.After executing the following code, what is the final value of the variable a?
>>> vowels = ['a','e','i','o','u']
python is cool
>>> i = 0
>>> a = 0
>>> while (i < len(text)):
>>> if (text[i] not in vowels):
>>> a = a + 3
>>> else:
>>> a = a + 1
>>> i = i + 1
Solve the exercise by tracing it, that is, show the value of the variables.
indicated in the table for each iteration of the while loop
i text[i] a
4/5
IES Sorolla
1. Practice
The following code in python draws a square of the dimensions and the pattern
indicated, but it has some errors in the lexicon and grammar, not semantic, it is
to say that it is not necessary to add or modify any instructions for it to do so
that you have to do. You will find the code at the following URL:
Invalid input. Please provide text for translation.
Correct and run the code in your usual development environment, once resolved.
the errors, save the file as ex1.pyy and send it to the indicated task.
rows?6
columns?3
pattern?
^^^
^^^
^^^
^^^
^^^
^^^
2. Implement the code of a program that, upon entering a word, indicates the
number of vowels and consonants it has
Hint: use the 'in' operator to check if a letter is a vowel or not; e.g.:
if letter in "aeiou":
Example
Count vowels and consonants
>>> ===================
baccalaureate
The word 'bachillerato' contains 7 consonants and 5 vowels.
3. Based on the solution of the previous exercise, modify the program so that
Once a word is introduced, indicate the number of different vowels and consonants.
Example
Count different vowels and consonants
>>> =========================
anguish
The word bachillerato contains 3 consonants and 2 vowels.
5/5