Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that creates a dictionary containing the Chinese provinces as keys and their capitals as values. (See table below or parse file

 imageimageimage

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 `} \]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Starting Out With Python Global Edition

Authors: Tony Gaddis

4th Edition

1292225750, 9781292225753

More Books

Students also viewed these Programming questions

Question

True or False You cannot directly call the _ _str_ _ method.

Answered: 1 week ago