Prepare > Python > Built-Ins > Python Evaluation
2023. 9. 28. 22:13ㆍHackerRank-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
'HackerRank-Python' 카테고리의 다른 글
Prepare > Python > Built-Ins > Athlete Sort (0) | 2023.10.01 |
---|---|
Prepare > Python > Built-Ins > Any or All (0) | 2023.09.29 |
Prepare > Python > Built-Ins > Input() (0) | 2023.09.27 |
Prepare > Python > Built-Ins > Zipped! (0) | 2023.09.26 |
Prepare > Python > Collections > Company Logo (0) | 2023.09.25 |