Week 8
Week 8
Create a Python script file (.py) for each problem, and compress them into a single zip file for
submission. Name the files as prob1, prob2, ..., prob7. Submit the compressed file to AJOU Black
board.
(각 문제마다 python script file(.py)을 만들고 하나로 압축하여 아주Bb에 제출하세요. 파일 이름은
prob1, prob2, ... prob7로 만드세요.)
1. Write a function readData() that takes two integers as input from the user and returns them. The
function should return the two integers as a tuple. To take two strings as input from the user,
you can use x, y = input("Enter two integers: ").split(). After receiving the input as strings, convert
them to integers and return the values.
2. Write a program that removes duplicate elements from a list of integers and then sorts the list.
Use a set to remove duplicates.
3. Write a program that creates a dictionary with numbers in the format (x, x*x) where x is a number
between 1 and 10 (inclusive). Then, print the dictionary.
Enter a key: 5
Key 5 is in the dictionary.
5. Write a program to calculate the total sum of the prices of all products stored in a dictionary,
where the dictionary contains the prices of items purchased from an online store.
myDict = { 'apple': 2.5, 'banana': 1.2, 'orange': 1.8, 'milk': 3.0, 'bread': 2.0}
Total: 10.50
6. Given two sets, set1 and set2, write a program to extract the elements that are present in
either set1 or set2, but not in both.
7. Write a program to combine two lists, one containing keys and the other containing values,
into a single dictionary.