What does eval() in Python do?

0 votes

In the book that I am reading on Python, it keeps using the code eval(input('blah'))

I read the documentation, and I understand it, but I still do not see how it changes the input()function.

What does it do? Can someone explain?

Aug 24, 2018 in Python by bug_seeker
• 15,360 points
57 views

1 answer to this question.

0 votes

The eval function lets a Python program run Python code within itself.

eval example (interactive shell):

>>> x = 1
>>> eval('x + 1')
2
>>> eval('x')
1

answered Aug 24, 2018 by Priyaj
• 56,940 points

Related Questions In Python

0 votes
1 answer

What does the return statement do in Python?

The print() function is use to write ...READ MORE

answered Oct 1, 2018 in Python by SDeb
• 13,190 points
109 views
0 votes
1 answer

What does hash do in python?

A hash is an fixed sized integer ...READ MORE

answered Oct 15, 2018 in Python by SDeb
• 13,190 points
38 views
0 votes
1 answer

What does hash do in python?

A hash is an fixed sized integer ...READ MORE

answered Nov 14, 2018 in Python by charlie_brown
• 7,720 points
67 views
+1 vote
1 answer

What does the Raise keyword do in Python?

Hi! I think I can answer this - ...READ MORE

answered Jan 25 in Python by Nymeria
• 3,520 points
82 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 351 views
+4 votes
6 answers
+3 votes
2 answers

What does Python _init_ and self do?

Hey @Anirudh!  Self The self keyword is used to access ...READ MORE

answered Oct 31, 2018 in Python by Omkar
• 67,660 points
301 views
0 votes
5 answers

What to study in Python to do freelancing using this?

Hello, you are on the right track. ...READ MORE

answered Feb 27 in Python by Priyaj
• 56,940 points
86 views