Skip to content

Instantly share code, notes, and snippets.

@shimizukawa
Last active May 19, 2017 14:39
Show Gist options
  • Save shimizukawa/e870369b20c089981850e40e02713b8c to your computer and use it in GitHub Desktop.
Save shimizukawa/e870369b20c089981850e40e02713b8c to your computer and use it in GitHub Desktop.
# 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