基础练习题-运算符

root
abc abc
  • 21 Jul

a=3//1.3

b=3//-2.5

c=3%2.5

d=-3%1.3

e=-3%-1.3

f=4*3**2%7//3/2
g=oct(123)
h=False or True and True or 7-9
print(f,g,h,0.4)

请问以上变量的值为多少?

import math

a=math.log2(7.8)

b=math.pow(1.9,1.9)

c= a if a>b else b

if a>b:

print("a>b")

c=a

if a>2:

pass

else:

print("a<=b")

c=b

for x in range(1,10):

print(f'x={x}')

i=31%6.0
print(f" 31%6.0={i}")
i=31%-6
print(f"31%-6={i}")
i=-31%-6
print(f"-31%-6={i}")
i=-31%6
print(f"-31%6={i}")

i=31//6
print(f"31//6={i}")
i=-31//-6
print(f"-31//-6={i}")
i=-31//6
print(f"-31//6={i}")
i=31//-6
print(f"31//-6={i}")

a=int(input("请输入一个年份:"))
b=False
if a%100==0:
if a%400==0:b=True
else:
if a % 4 == 0:b=True

if b==True:print("Yes!")
else:print("No!")

b=(a%400==0) or (a%100!=0 and a%4==0)

c=10 if 23<45*45/98 else 20 #条件运算符

a=int(input("请输入一个分数:"))
if a>=90:print("A")
elif a>=80:print("B")
elif a>=70:print("C")
elif a>=60:print("D")
else:print("E")
help(range)

if a%2==0:

print("这是偶数")

if a>=10:

print("这是大于10的偶数")

else:

print("这是不大于10的偶数")

else:

print("这是奇数")

print("the end!")