d = dict() 
d = {}
 
type(d)
 
dict
 
list1 = [("a",'ok'),('1','lk'),("001",'lk')]   
d1 = dict(list1)
print(d1)
 
{'a': 'ok', '1': 'lk', '001': 'lk'}
 
list11 = [("a",'ok'),('a','lk'),("001",'lk')]   
d11 = dict(list11)     
print(d11)
 
{'a': 'lk', '001': 'lk'}
 
list2 = [["a",'ok'],['b','lk'],["3",'lk']]  
d2 = dict(list2)
print(d2)
 
{'a': 'ok', 'b': 'lk', '3': 'lk'}
 
t1 = (("a",'ok'),('b','lk'),("001",'lk'))  
d3 = dict(t1)    
print(d3)
 
{'a': 'ok', 'b': 'lk', '001': 'lk'}
 
t2 = (["a",'ok'],['b','lk'],["001",'lk'])  
d4 = dict(t2)    
print(d4)
 
{'a': 'ok', 'b': 'lk', '001': 'lk'}
 
print("d3字典中键b对应的值为:",d3.get("b"))
 
d3字典中键b对应的值为: lk
 
d.setdefault("a",0)    
print(d)
 
{'a': 0}
 
d4.setdefault("c",45)   
print(d4)
 
{'a': 'ok', 'b': 'lk', '001': 'lk', 'c': 45}
 
d4
 
{'a': 'ok', 'b': 'lk', '001': 'lk', 'c': 45}
 
d0 = {}
d0.setdefault("c",[1,2,3,4,5])
print(d0)
 
{'c': [1, 2, 3, 4, 5]}
 
 
x = 10
import math     
if x > 0:
    s = math.sqrt(x)     
    print("x的平方根为:",s)
 
x的平方根为: 3.1622776601683795
 
y = 100
import math     
if y > 0:
    s1 = math.sqrt(y)     
print("y的平方根为:",s1)   
 
y的平方根为: 10.0
 
x1 = -10
import math     
if x1 > 0:                 
    s2 = math.sqrt(x1)     
    print("x1的平方根为:",s2)
 
 
y1 = -10
if y1 >= 0:
    sq = math.sqrt(y1)    
    print("sq = ",sq)
else:
    print("负数不能求平方根")
 
负数不能求平方根
 
 
weather = "sunny"
if weather == "sunny":
    print("shoping")
elif weather =="cloudy":
    print("playing football")
else:
    print("do nothing")
 
shoping
 
 
score = 75
if 100 >= score >= 90:     
    print("A")
if 90 > score >= 80:
    print("B")
if 80 > score >= 70:
    print("C")   
if 70 > score >= 60:
    print("D")
if 60 > score :
    print("E")
if score < 0 or score > 100:
    print("输入错误,请检查!")
 
C
 
score = 109
if 100 >= score >= 90:     
    print("A")
if 90 > score >= 80:
    print("B")
if 80 > score >= 70:
    print("C")   
if 70 > score >= 60:
    print("D")
if 60 > score :
    print("E")
if score < 0 or score > 100:
    print("输入错误,请检查!")
 
输入错误,请检查!