Create a program that works with your favorite movies.
Create a list called movies containing 5 movie titles.
Use a for loop to print all movies.
Use a for loop to print only movies whose titles contain more than 5 characters.
Add another movie to the list using append().
Create a set called unique_movies from the movies list.
Create a tuple called genres containing 4 movie genres.
Use a for loop to print all movie genres.
Method Description
dict.keys() returns all keys
dict.values() returns all values
dict.items() returns all keys and values
dict.get(key) safe access to values
dict.pop(key) removes and returns value
Create a dictionary student with the following data:
"name": "Peter"
"age": 21
"study_program": "Computer Science"
Print all keys and values.
Add a new key year with the value 2 to the existing dictionary student, and change age to 22.
For the given dictionary:
employee = {
"name": "Jana",
"position": "accountant",
"salary": 1300
}
Print each key and its value in the format:
name: Jana
position: accountant
salary: 1300
From the dictionary products = {“apple”: 0.5, “pear”: 0.7, “banana”: 0.5} remove all items with the value 0.5.
For the dictionary countries = {“Slovakia”: “Bratislava”, “Czech Republic”: “Prague”} create a new one where the keys become values and values become keys.
You have two dictionaries:
daily_sales1 = {"apple": 3, "pear": 2}
daily_sales2 = {"apple": 4, "banana": 5}
Create a single dictionary that contains all items. If keys repeat, sum their values. The output should look like this:
{"apple": 7, "pear": 2, "banana": 5}
Create a function word_count_dict(sentence) that returns a dictionary where the keys are words and the values are the number of their occurrences in the sentence. Example:
word_count_dict("dog meow dog meow meow")
Output:
{'dog': 2, 'meow': 3}
Call the function mince 10 times using a loop. 3. Modify the previous program so that only coins with values 1, 2, 5, 10, 20, 50 are generated.
When generating the coin values, use the command:
random.choice([1, 2, 5, 10, 20, 50])
random.choice([‘silver’, ‘gold’, ‘white’])
and use this variable in the drawing command fill=farba.
Try to reply with a similar message. Write a program called ufo_sprava.py that randomly generates such a message according to the following rules: