Prepare > Python > Built-Ins > Python Evaluation

2023. 9. 28. 22:13HackerRank-Python

 

Python Evaluation | HackerRank

Evaluate the expressions in Python using the expression eval().

www.hackerrank.com

 

문제


Task
You are given an expression in a line. Read that line as a string variable, such as var, and print the result using eval(var).

 

=> eval() 을 이용해 결과를 출력해라

 

 

 

 

코드


eval(input())

 

 

 

 

노트


print(eval(input()))

"""
5
None
"""
  • input으로 받아온게 "print(2 + 3)" 이므로 eval로 실행한 뒤 남는게 없기에 None 출력

 

 

 

 

참조


 

Prepare > Python > Built-Ins > Input()

Input() | HackerRank A Python 2 challenge: Input() is equivalent to eval(raw_input(prompt)). www.hackerrank.com 문제 Task You are given a polynomial P of a single indeterminate (or variable), x. You are also given the values of x and k. Your task is to v

my-little-diary.tistory.com