Question: Write a code segment that prompts the user for a filename. If the file exists, the program should print its contents on the terminal. Otherwise,
Write a code segment that prompts the user for a filename. If the file exists, the program should print its contents on the terminal. Otherwise, it should print an error message.
Jack is developing a program that calls for converting a list of words to uppercase. He tries out a strategy for this task in the Python shell, as follows:
listOfWords Apple "orange", "banana"
for word in listOfWords:
word word.upper
listOfWords
Apple 'orange', 'banana'
Jacks strategy does not appear to produce the expected result. Describe the error, explain why it happened, and suggest a correction.
Assume that the variable data refers to the dictionary b:a: Write the expressions that perform the following tasks:
Replace the value at the key b in data with that values negation.
Add the keyvalue pair c: to data.
Remove the value at key b in data, safely.
Print the keys in data in alphabetical order.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
