Describe how catching exceptions can help with file errors. Write three Python examples that actually generate file errors on your computer and catch the errors with try: except: blocks. Include the code and output for each example in your post.
Describe how you might deal with each error if you were writing a large production program. These descriptions should be general ideas in English, not actual Python code.
Comment your code to demonstrate that you know what you are talking about!
Write a program that asks the user to enter a number between 1 and 100 in a form. If the
number is less than 10, display “That’s really small.” If it’s between 10 and 50, say “not too big.”
If it’s more than 50, display “That’s a big one!”
We've already tried comparing 3 numbers to see the largest among all, so let's try a more complicated mission where we locate the position of the largest among 5 numbers. There are only 4 possible cases for this mission:
- if the largest digit is the first digit, print "Leftmost"
- if the largest digit is the third digit, print "Middle"
- if the largest digit is the last digit, print "Rightmost"
- if none of the above is correct, print "Unknown"
Now, show me how far you've understood your lessons!
Input
A line containing a five-digit integer.
1·4·6·3·2Output
A line containing a string.
MiddleI'm quite into games now, so how about we play In or Out! When a given number is even, the team scores so we shall print "In", but if it's not an even number, then we print "Out". Simple, right?
Now let's get this game started.
Input
A line containing an integer.
35Output
A line containing a string.
OutUsing a Decision Control Structure (if), create a flowchart and a java program that
reads a commodity code, quantity of the commodities bought and the unit price and
output the amount to be paid by the customer.
Write a program to calculate an Internet browsing bill. Use the conditions specified as follows:
1 hour-Rs 40
½ hour- Rs 20
For unlimited hours in a day- Rs 200
The owner should enter the number of hours spent on browsing.