python课堂作业_python课堂作业:1-2-3-4,PythonClasswork1234

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 "", line 3

wwww''''

^

SyntaxError: EOL while scanning string literal

>>> ''htzd

File "", 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 "", line 1

SyntaxError: can't assign to literal

>>> (2-1)+1

2

>>> (2-1)=1

File "", line 1

SyntaxError: can't assign to operator

>>> (2-1)==1

True

>>> 2=1

File "", 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("加法演示,""作者:朱航钰")

print("-"*20)

firstNum=float(input("First Num:"))

print("-"*20)

secondNum=float(input("Second Num:"))

print("-"*20)

print("firstNum+secondNum={}+{}={}".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 "", line 1, in

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 "", line 1, in

NameError: name 'log3' is not defined

>>> log2(10)

3.321928094887362

>>> log10(100)

2.0

>>> radians(180)

3.141592653589793

>>>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值