Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Starting with the file exceptions.py, implement exception handling for two types of exceptions that could occur for this code. In your exception handling code indicate:
a. What type of exception occurred
b. What values of p1 and p2 caused the exception
Note 1: you will need to determine the type of parameters used to call this function.
Note 2: Include at least two types of exceptions.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 2 steps with 2 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Create a function called get_age() to input the user's age. If the user enters a value that is outside the specified range, throw a ValueError exception. Create a function called fat_burning_heart_rate() to calculate and return the heart rate. Try getting the user age input in main() along with the exception handling. Prompt the user to continue the program with another age until the user indicates to quit. I have all of the main code written but I can't seem to figure out how to get it all within a main function that will restart when the user types yes and print bye bye for no. This is the kind of output I want: This program calculates the fat-burning heart rate based on age.Enter an age between 18-75: 35Fat burning heart rate for a 35 year-old: 129.5 bpmWould you like to try another age? (yes/no)yesEnter an age between 18-75: 17Invalid age.Could not calculate heart rate info.Would you like to try another age? (yes/no)yesEnter an age between 18-75: 18Fat burning heart…arrow_forwardcould you include a try-catch statement that calls the GetYear function defined above. If a BadYear exception is thrown, print an error message and rethrow the exception to a caller; otherwise, execution should just continue as normal.arrow_forwardModify the GreenvilleRevenue program created in Chapter 10, Case Study 1 so that it performs the following tasks: The program prompts the user for the number of contestants in this year’s competition; the number must be between 0 and 30. Use exception-handling techniques to ensure a valid value and display the error message:Number must be between 0 and 30 The program prompts the user for talent codes. Use exception-handling techniques to ensure a valid code and update the displayed message to the following message:x is not a valid talent code. Assigned as Invalid.where x was the invalid code entered into the console. After data entry is complete, the program prompts the user for codes so the user can view lists of appropriate contestants. Use exception-handling techniques for the code verification and display the following message: Enter a talent type or Z to quit >> x x is not a valid code and for valid codes: Enter a talent type or Z to quit >> S Contestants with talent…arrow_forward
- The Third program needs to handle data from files (open, read/write, delete to handle data). It uses exception handling – try and except to catch and handle exceptions. Follow coding standards, naming conventions for variables and functions. Students will be asked to explain the working of their program and the logic they’ve used.arrow_forwardDescribe the purpose and use of the "try-catch" block in exception handling.arrow_forwardPlease give the names of the various approaches of managing exceptions that are available.arrow_forward
- We have created a hierarchy of exceptions like below: A) The code written below throws an exception from the above hierarchy, depending on the value of c. Fill in the 5 gaps below, so that a correct working program is created. B) the following code throws two exceptions: Exception and ExceptionD. The exception name in the catch statement was removed as I expect you to recognize the order by which the exceptions are written in this code. B-1) what will be printed if the method is called by x = 0. B-2) what will be printed if the method is called by x = -1. B-3) what will be printed if the method is called by x = 1. C) A class called Exam is defined as below. Another class called TT2 extends class Exam and overrides all the three methods of Exam class. Specify what type of exceptions can be thrown by the methods that are defined in class TT2.arrow_forward4043143640684x3y7 In the code below, we compute the sum of integers in a file by reading them one line at a time. Rearrange the following lines of code so that the input file is closed even if the int function raises an exception. Follow Programming Tip "Do not use except and finally in the same try statement" in the Exception Handling section by placing the try block and finally clause inside the outer try block. How to use this tool Unused try : Check You've added 7 blocks, but 8 were expected. Not all tests passed. 1: Compare output Input Your output X 2: Compare output Input Output differs. See highlights below. Special character legend Your output numbers1.txt Expected output Total: 100 Closing file numbers2.txt Tester.py total = 0 infile open (input()) try: Total: 554 Closing file Error: Not an integer value. except ValueError : Error: Not an integer value. Total: 554 Closing file for line in infile : value = int(line) total= total + value finally : print("Error: Not an integer…arrow_forward"In PHP, reusable code can be inserted into every module using which function?" include() call() copy() insert() QUESTION 12 "Is software development testing phase, the first test is done by a developer after changing code or creating new code. What do you call this phase of testing?" Development test Unit test System test Integration test QUESTION 13 "In PHP, if an exception is not caught, a fatal error will be issued with a(n). Not found System Uncaught Exception Error message." QUESTION 14 Which PHP function replaces some characters with some other characters in a string or arrays? find_replace() str_replace() changestr() replace()arrow_forward
- Programming Problem 1 – CycleThrowTryCatch Revisit the Cycle class in Module 3. Modify your application such that the properties, numberOfWheels and weightare entered as double values interactively (at the keyboard). Exception handling will be used to determine whether a type mismatch occurs. Edit your application such that, in addition to [A], the values for numberOfWheels and weight, entered interactively, will throw a new exception “Values cannot be less than or equal to zero” only If the values are less than or equal to zero. Add or use the appropriate try and/or catch blocks. Directions Examine your application for the class called Cycle. Add Try and Catch blocks appropriately. Add the throw statement for the new exception. Display an appropriate message if an exception occurs. Display the properties of the object.arrow_forward11- When a Python program crashes with an exception, what would you generally expect to find as part of the displayed error output? a. The text "ValueError", which is always included in exception output. b. The number of statements executed before the exception was encountered. c. The dedicated rule yield (DRY) of the program so far. d. A McDonald's job application form, because professional programmers don't make errors. e. The exact time that the exception was raised at. f. The source code line number that the exception was raised from.arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education