Question
Help with Python please. I cannot figure out how to do step 3. Step 1: Producing correct output Three commented-out lines of code exist in
Help with Python please. I cannot figure out how to do step 3.
Step 1: Producing correct output
Three commented-out lines of code exist in the main part of the program. Uncomment the lines and click the "Run program" button. Verify that the program's output is:
2 + 2 = 4 Unknown method: print_plus_2 Secret string: "abc"
Submit your code for grading. Your submission will pass the "Compare output" test only, achieving 1 of the possible 10 points.
Step 2: Inspecting the LabPrinter class
Inspect the LabPrinter class implemented in the LabPrinter.py file. Access LabPrinter.py by clicking on the orange arrow next to IntroToDSELabs.py at the top of the coding window. Instance methods print_2_plus_2() and print_secret() print strings using print().
Step 3: Implementing call_method_named()
Remove the three uncommented lines from the main part of the program. Then implement the call_method_named() function in IntroToDSELabs.py to handle three cases:
If method_name is "print_2_plus_2", call printer's print_2_plus_2() instance method.
If method_name is "print_secret", call printer's print_secret() instance method.
If method_name is anything other than the two strings mentioned above, print "Unknown method: xyz", where xyz is method_name's value.
After implementing call_method_named(), click the "Run program" button. Verify that the program's output is, once again:
2 + 2 = 4 Unknown method: print_plus_2 Secret string: "abc"File is marked as read only Current file: LabPrinter.py
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started