Last active
May 19, 2017 14:39
-
-
Save shimizukawa/e870369b20c089981850e40e02713b8c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I want display calculation tutorial with using PythonAnywhere. But I worry about that this code will confuse students. | |
# run this code on: https://www.pythonanywhere.com/gists/e870369b20c089981850e40e02713b8c/type-int.py/python3/ | |
import time | |
import sys | |
ps1 = '>>> ' | |
def emulate(text): | |
print(ps1, sep='', end='') | |
sys.stdout.flush() | |
time.sleep(2) | |
print(text) | |
exec('print(' + text + ')') | |
emulate('2 + 2') | |
emulate('3 - 8') | |
emulate('6 * 9') | |
emulate('8 / 2') | |
emulate('5 % 2') | |
emulate('5 ** 2') | |
print() | |
print('######## Please input your code!') | |
print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment