4.
a. Create a dictionary named d1, which has three key-value pairs, so that there is one key of each data type: str, int, float.
b. Create an empty dictionary named d2
c. Go in a loop on all keys of d1, and insert them as values into d2. The keys of d2 will be the values from d1 (the inversion of keys and values)
d. The action may fail. If it fails, try to understand when the operation will fail and when it will succeed.
5.
a. Write a function named build_encrypt_code. The function builds an encryption dictionary that consists of hundreds as a key and a number as a value. For example:
{'a': 7, 'b': 1, 'c': 6, 'd': 0, 'e': 5, 'f' I ': 2,' j ': 8}
b. Write a punctuation called encrypt. The function accepts the dictionary from a and a one-word string, and encrypts the string according to the dictionary. If the letter does not exist in the dictionary, write it without encryption. Big and small letters are translated in the same way. For example, the letters A and A will be paired to number 7.
c. Write a master program that asks the user for a string and uses both functions to encrypt the string. The program prints the encrypted string.
1. Write a program that asks the user for a file name (including its path). The program will ask the user for 5 sentences and write them down to the group.
2. Write a program that prints random numbers into a file named numbers.txt. Each random number is in the range between 1 and 500. The user determines how many such numbers should be printed to a file. To generate numbers, ranges in the range between 1 and 500 record the following commands:
Import random
Random.randint (1,500)
3. Create a file named file1.txt that contains the following sentences:
Python is a great language.
I love python.
I thik Java is better.
When is the next python lesson? I simply can not miss it!
\ Write a program that reads all rows to a list named list1 (each line will be inserted as an item into list1). Go to the list and remove any entries that do not have the word Python (regardless of the uppercase or lowercase letter).
If you have to remove even one line, add the line to this file: This file is corrupt.
a. Create a dictionary named d1, which has three key-value pairs, so that there is one key of each data type: str, int, float.
b. Create an empty dictionary named d2
c. Go in a loop on all keys of d1, and insert them as values into d2. The keys of d2 will be the values from d1 (the inversion of keys and values)
d. The action may fail. If it fails, try to understand when the operation will fail and when it will succeed.
5.
a. Write a function named build_encrypt_code. The function builds an encryption dictionary that consists of hundreds as a key and a number as a value. For example:
{'a': 7, 'b': 1, 'c': 6, 'd': 0, 'e': 5, 'f' I ': 2,' j ': 8}
b. Write a punctuation called encrypt. The function accepts the dictionary from a and a one-word string, and encrypts the string according to the dictionary. If the letter does not exist in the dictionary, write it without encryption. Big and small letters are translated in the same way. For example, the letters A and A will be paired to number 7.
c. Write a master program that asks the user for a string and uses both functions to encrypt the string. The program prints the encrypted string.
1. Write a program that asks the user for a file name (including its path). The program will ask the user for 5 sentences and write them down to the group.
2. Write a program that prints random numbers into a file named numbers.txt. Each random number is in the range between 1 and 500. The user determines how many such numbers should be printed to a file. To generate numbers, ranges in the range between 1 and 500 record the following commands:
Import random
Random.randint (1,500)
3. Create a file named file1.txt that contains the following sentences:
Python is a great language.
I love python.
I thik Java is better.
When is the next python lesson? I simply can not miss it!
\ Write a program that reads all rows to a list named list1 (each line will be inserted as an item into list1). Go to the list and remove any entries that do not have the word Python (regardless of the uppercase or lowercase letter).
If you have to remove even one line, add the line to this file: This file is corrupt.