0% found this document useful (0 votes)
4 views1 page

User Input Validation Programs

The document outlines ten programming tasks that involve user input and exception handling. These tasks include operations such as division, age input validation, list indexing, temperature conversion, string manipulation, sum calculation, word counting, average computation, temperature conversion between Kelvin and Celsius, and file handling. Each task emphasizes the importance of managing invalid inputs and errors effectively.

Uploaded by

bibaswan.2.patra
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

User Input Validation Programs

The document outlines ten programming tasks that involve user input and exception handling. These tasks include operations such as division, age input validation, list indexing, temperature conversion, string manipulation, sum calculation, word counting, average computation, temperature conversion between Kelvin and Celsius, and file handling. Each task emphasizes the importance of managing invalid inputs and errors effectively.

Uploaded by

bibaswan.2.patra
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1. Write a program that takes two numbers from the user and performs division.

Handle cases
where the user inputs non-numeric values or tries to divide by zero.

2. Create a program that asks the user to input their age. If the user enters a negative value or a
non-numeric input, raise an appropriate exception and prompt the user again.
3. Write a program that takes an index and returns the corresponding element from a list. If the
index is out of range or the input is invalid, handle the exception.
4. Write a program that converts temperatures between Celsius and Fahrenheit. The user should
be able to input the temperature scale and value. Handle invalid inputs and display
appropriate error messages.
5. Write a program that asks the user to enter a string and then reverses it. Handle cases where
the user enters an empty string or non-string input.
6. Write a program that calculates the sum of numbers in a list. If the list is empty, raise an
exception and handle it.
7. Write a program that counts the number of words in a given string. Handle empty strings and
invalid inputs.
8. Write a program that reads a series of numbers from the user, calculates the average, and
handles cases where the user enters invalid data or no data at all.
9. Write a program that converts temperatures from Kelvin to Celsius and vice versa. Handle
invalid inputs.
10. Write a program that asks for a filename, attempts to open it, and reads its content. Handle
the FileNotFoundError and PermissionError.

You might also like