Ejercicio Tema 2 Python
Ejercicio Tema 2 Python
1.1. Simple Message: Store a message in a variable, and then print that message.
1.2. Simple Messages: Store a message in a variable and print that message. Then change the
value of your variable to a new message and print the new message.
2. Save each of the following exercises as a separate file with a name like name_cases.py. If you
get stuck, “ask for help”!
2.1. Personal Message: Store a person’s name in a variable and print a message to that person.
Your message should be simple, such as, “Hello Eric, would you like to learn some Python
today?”
2.2. Name Cases: Store a person’s name in a variable, and then print that person’s name in
lowercase, uppercase, and title case.
2.3. Famous Quote: Find a quote from a famous person you admire. Print the quote and the
name of its author. Your output should look something like the following, including the
quotation marks: Albert Einstein once said, “A person who never made a mistake never
tried anything new.”
2.4. Famous Quote 2: Repeat Exercise 2.3, but this time store the famous person’s name in a
variable called famous person. Then compose your message and store it in a new variable
called message. Print your message.
2.5. Stripping Names: Store a person’s name and include some whitespace characters at the
beginning and end of the name. Make sure you use each character combination, "\t" and "\
n", at least once. Print the name once, so the whitespace around the name is displayed. Then
print the name using each of the three stripping functions, lstrip(), rstrip(), and strip().
2.6. Number Eight: Write addition, subtraction, multiplication, and division operations that
each result in the number 8. Be sure to enclose your operations in print statements to see the
results.
Alumno/a:
[email protected]
Curso: www.iesluisbraille.es
Otros alumnos/as del grupo:
You should create four lines that look like this:
-------------------------------------------------------------------------------------------------------------
print(5 + 3)
------------------------------------------------------------------------------------------------------------
Your output should simply be four lines with the number 8 appearing once on each line.
2.7. Favourite Number: Store your favourite number in a variable. Then, using that variable,
create a message that reveals your favourite number. Print that message.
2.8. Adding Comments: Choose two of the programs you’ve written and add at least one
comment to each. If you don’t have anything specific to write because your programs are
too simple at this point, just add your name and the current date at the top of each program
file. Then write one sentence describing what the program does.
2.9. Zen of Python: Enter import this into a Python terminal session and skim through the
additional principles.
Alumno/a:
[email protected]
Curso: www.iesluisbraille.es
Otros alumnos/as del grupo: