You are on page 1of 15

HAMZA JAMIL

02-131232-041
INTRODUCTI
ON TO INPUT
METHODS IN
PYTHON :
•Python provides various
methods for accepting user
input during program
execution.
•These input methods allow
interaction with the user,
enabling dynamic and
personalized experiences.
EXAMPLE OF INPUT() FUNCTION:
eval(input()) Function:
Accepts user input and evaluates it as a Python expression. Use when expecting more complex input
or when performing calculations based on user input.
eval() is a built-in Python function that evaluates a string as a Python expression and returns the result.
It allows you to dynamically execute code that is represented as a string.

Here's an example to illustrate how eval() works:

In this example, the string "2 + 3 * 5" is stored in the variable expression. The eval() function then
evaluates this string as a Python expression and computes the result, which is assigned to the
variable result. The final output will be 17 since the expression is evaluated following the order of
operations in mathematics.
READING INPUT FROM FILES IN PYTHON:
READING INPUT FROM FILES:
READING INPUT FROM FILES :
HANDLING SPECIFIC EXCEPTIONS IN PYTHON:
EXAMPLE:
CONCLUSION:
In conclusion, user input plays a crucial role in programming and is essential for creating
dynamic and responsive programs. By incorporating user feedback and preferences,
programmers can create programs that are tailored to the needs and expectations of their users.
This not only improves the user experience but also enhances the overall performance and
functionality of the program.

You might also like