Classwork-1:
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> 1+1 2 >>> 5*6 30 >>> 8-4 4 >>> 40/5 8.0 >>> 5/3 1.6666666666666667 >>> 5//3 1 >>> 5%3 2 >>> (6+4)*5/2 25.0 >>> 3.141592654*3.141592654 9.869604403666765 >>> 'networe' 'networe' >>> 'network' 'network' >>> "network" 'network' >>> '''htzd''' 'htzd' >>> "htzd" 'htzd' >>> '''htzd.... ... org ... wwww'''' File "<stdin>", line 3 wwww'''' ^ SyntaxError: EOL while scanning string literal >>> ''htzd File "<stdin>", line 1 ''htzd ^ SyntaxError: invalid syntax >>> '''htzd ... org ... wwww''' 'htzd\norg\nwwww' >>> 2>1 True >>> 3<4 True >>> 2<1 False >>> (3+4)<3 False >>> 1+1 2 >>> 1=1 File "<stdin>", line 1 SyntaxError: can't assign to literal >>> (2-1)+1 2 >>> (2-1)=1 File "<stdin>", line 1 SyntaxError: can't assign to operator >>> (2-1)==1 True >>> 2=1 File "<stdin>", line 1 SyntaxError: can't assign to literal >>> a=1 >>> a=2 >>> a 2 >>> b=3 >>> +b 3 >>> a+b 5 >>> (a+b)*10-2 48 >>> print("htzd") htzd >>> "htzd" 'htzd' >>> print(b-a) 1 >>>Classwork-2:
a=int(input("a=")) b=int(input("b=")) print("a+b=%d+%d=%d"%(a,b,a+b)) import math # 计算圆面积 radius=5.2 #给半径赋值 area=math.pi*radius*radius print("Circle Area:%.2f"%(area))Classwork-3:
print("加法演示,""作者:gCode.top") print("-"*20) firstNum=float(input("First Num:")) print("-"*20) secondNum=float(input("Second Num:")) print("-"*20) print("firstNum+secondNum={0}+{1}={2}".format(firstNum,secondNum,firstNum+secondNum)) import math radius=5.12 area=math.pi*radius*radius print("1.Circle Area:",area) print("2.Circle Area:%0.2f"%(area)) print("3.Circle Area:{0:.2f}".format(area))Classwork-4:
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import math >>> math.sin(0.5) 0.479425538604203 >>> import random >>> random.random() 0.6542752319264754 >>> random.randint(1,100) 23 >>> random.randint(1,100) 61 >>> random.randint(1,100) 42 >>> random.randint(1,100) 96 >>> random.randint(1,100) 61 >>> random.randrange(1,100) 96 >>> random.randrange(1,100) 28 >>> random.randrange(1,100) 55 >>> >>> >>> random.randrange(1,100) 29 >>> import os.path as path >>> path.isfile(r'c:\eula.1028.txt') True >>> import numpy as np Traceback (most recent call last): File "<stdin>", line 1, in <module> ModuleNotFoundError: No module named 'numpy' >>> Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from math import sin >>> sin(2) 0.9092974268256817 >>> from math import sin as f >>> f(2) 0.9092974268256817 >>> from os.path import isfile >>> isfile(r'c:\eula.1028.txt') True >>> Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from math import * >>> gcd(16,18) 2 >>> gcd(36,18) 18 >>> pi 3.141592653589793 >>> e 2.718281828459045 >>> log2(8) 3.0 >>> log2(9) 3.169925001442312 >>> log3(9) Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'log3' is not defined >>> log2(10) 3.321928094887362 >>> log10(100) 2.0 >>> radians(180) 3.141592653589793 >>>
