Write a program that creates a dictionary containing the Chinese provinces as keys and their capitals...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a program that creates a dictionary containing the Chinese provinces as keys and their capitals as values. (See table below or parse file chinese-provincial-capitals.txt (link) The program should then randomly quiz the user by displaying the name of a province and asking the user to enter that province's capital. The program should keep a count of the number of correct and incorrect responses. PROVINCE CAPITAL Anhui Hefei Fujian Fujian Gansu Lanzhou Guangdong Guangzhou Guizhou Guiyang Hainan Haikou Hebei Shijiazhuang Heilongjiang Harbin Henan Zhengzhou Hubei Wuhan Hunan Changsha Jiangsu Nanjing Jiangxi Nanchang Jilin Changchun Liaoning Shenyang Qinghai Xining Shaanxi Xian Shandong Jinan Shanxi Taiyuan Sichuan Chengdu Yunnan Kunming Zhejiang Hangzhou chinese-provincial-capitals - Notepad File Edit View PROVINCE, CAPITAL Anhui,Hefei Fujian,Fujian Gansu,Lanzhou Guangdong,Guangzhou Guizhou,Guiyang Hainan, Haikou Hebei, Shijiazhuang Heilongjiang,Harbin Henan,Zhengzhou Hubei,Wuhan Hunan,Changsha Jiangsu,Nanjing Jiangxi, Nanchang Jilin,Changchun Liaoning,Shenyang Qinghai,Xining Shaanxi,Xian Shandong,Jinan Shanxi,Taiyuan Sichuan,Chengdu Yunnan Kunming Exercise 3 - (Gaddis 9.3) File Encryption and Decryption Write a program that uses a dictionary to assign "codes" to each letter of the alphabet. For example: >>>|codes = {'A': '%, a:9, B:@,b:#} Using this example, the letter A would be assigned the symbol %, the letter a would be assigned the number 9, the letter B would be assigned the symbol and so forth. The program should open a specified text file, read its contents, and then use the dictionary to write an encrypted version of the file's contents to a second file. Each character in the second file should contain the code for the corresponding character in the first file. Write a second program that opens an encrypted file and displays its decrypted contents on the screen. link for codes that can be used %% @ # 1 P 3 a 5 ^ 7 = 07 {0 [: Z. j % ") ; 2 h~ P 9 $ # ^ 4 ^ 6 ) 8 `} \] Write a program that creates a dictionary containing the Chinese provinces as keys and their capitals as values. (See table below or parse file chinese-provincial-capitals.txt (link) The program should then randomly quiz the user by displaying the name of a province and asking the user to enter that province's capital. The program should keep a count of the number of correct and incorrect responses. PROVINCE CAPITAL Anhui Hefei Fujian Fujian Gansu Lanzhou Guangdong Guangzhou Guizhou Guiyang Hainan Haikou Hebei Shijiazhuang Heilongjiang Harbin Henan Zhengzhou Hubei Wuhan Hunan Changsha Jiangsu Nanjing Jiangxi Nanchang Jilin Changchun Liaoning Shenyang Qinghai Xining Shaanxi Xian Shandong Jinan Shanxi Taiyuan Sichuan Chengdu Yunnan Kunming Zhejiang Hangzhou chinese-provincial-capitals - Notepad File Edit View PROVINCE, CAPITAL Anhui,Hefei Fujian,Fujian Gansu,Lanzhou Guangdong,Guangzhou Guizhou,Guiyang Hainan, Haikou Hebei, Shijiazhuang Heilongjiang,Harbin Henan,Zhengzhou Hubei,Wuhan Hunan,Changsha Jiangsu,Nanjing Jiangxi, Nanchang Jilin,Changchun Liaoning,Shenyang Qinghai,Xining Shaanxi,Xian Shandong,Jinan Shanxi,Taiyuan Sichuan,Chengdu Yunnan Kunming Exercise 3 - (Gaddis 9.3) File Encryption and Decryption Write a program that uses a dictionary to assign "codes" to each letter of the alphabet. For example: >>>|codes = {'A': '%, a:9, B:@,b:#} Using this example, the letter A would be assigned the symbol %, the letter a would be assigned the number 9, the letter B would be assigned the symbol and so forth. The program should open a specified text file, read its contents, and then use the dictionary to write an encrypted version of the file's contents to a second file. Each character in the second file should contain the code for the corresponding character in the first file. Write a second program that opens an encrypted file and displays its decrypted contents on the screen. link for codes that can be used %% @ # 1 P 3 a 5 ^ 7 = 07 {0 [: Z. j % ") ; 2 h~ P 9 $ # ^ 4 ^ 6 ) 8 `} \]
Expert Answer:
Related Book For
Posted Date:
Students also viewed these programming questions
-
Write a program that creates a dictionary containing the U.S. states as keys, and their capitals as values. #The program should then randomly quiz the user (you may limit the number of random quizzes...
-
Can standing waves be formed of transverse waves, longitudinal waves, or both?
-
If f : [a, b] [a, b] is continuous, then f has a fixed point; that is, there is a c [a, b] such that f(c) = c.
-
Public Company acquired the net assets of Sun Company by paying cash $420,000. At that time, the book value of the net assets of Sun Company was $300,000 and the fair value its net assets was...
-
For a random sample of n = 49, find the probability of a sample mean being less than 37.2 when = 38 and = 2.17. The population mean and standard deviation are given. Find the indicated probability...
-
Haversham Corporation produces dress shirts. The company uses a standard costing system and has set the following standards for direct materials and direct labor (for one shirt): Fabric (1.5 yds. @...
-
(a) Apply your linear regression model using gradient descent to find the best fit of the data given by: x = np.array([ 0., 1.66666667, 3.33333333, 5.0, 6.66666667, 8.33333333, 10.0, 11.66666667,...
-
Which report lists detailed information about invoices paid against a specific obligation?
-
Explain the influence of contract preconditions and exceptions in dynamic models. How do they affect the complexity of the dynamic model?
-
Which of these has a frustrationregression element? Safety needs Social needs Growth needs Self-actualization
-
Elaborate a list of concepts and subconcepts (subtypes of the original concept, e.g., dog and beagle) from common sense. Then, try to identify the type of each relation: structural, associative, or...
-
How does a tax- deferred transaction impact the holding period of an asset?
-
_________ are related to relational aspects and involve a sense of belongingness. Safety needs Social needs Esteem needs Self-actualization
-
Your engineering friend has decided to quit his $150,000 a year job and has $500,000 in funds. He wants to explore opening a Taproom serving local micro-brews in a strip mall location and believes...
-
Is it ethical to provide safety training in English to immigrant workers who speak little English, in order to reduce costs?
-
A construction contract differs from contracts that we generally deal with that focus on an easily defined physical object because the physical object can be examined. How is the object of a...
-
What does the owner contribute to the project and what does the contractor contribute to the project?
-
The construction schedule is the only project document that fully communicates the contractor's intentions for delivering the contracted scope of services over the full course of the project...
Study smarter with the SolutionInn App