PW1 python
PW1 python
Practical Work 01
(1h 30min) 10 minutes for each exercise
Write a script that asks the user for their age and prints the following messages based on the
entered value:
Write a script that prompts the user for a number (1 to 7) and prints the corresponding day of
the week using the match-case statement. Handle any input that is not in the range of 1 to 7
by printing an error message.
Write a script that uses a for loop to compute the sum of all numbers from 1 to a user-
provided number (n). Print the sum at the end.
Write a script that asks the user for a number and prints the multiplication table for that
number from 1 to 10 using a for loop and range().
Write a script that uses the zip() function to pair two lists of equal length (names and
scores). The script should print each name along with the corresponding score
Page 1 sur 2
names = ["Alice", "Bob", "Charlie"]
scores = [85, 90, 78]
Alice: 85
Bob: 90
Charlie: 78
Write a script that repeatedly prompts the user to enter a positive integer. If the user enters a
negative number or zero, print an error message and prompt them again. Use break to stop
the loop when a valid input is received.
Write a script that uses a for loop to print all odd numbers between 1 and 20. Use the
continue statement to skip even numbers.
Page 2 sur 2