round(4.5676,2)?
Answer: 4.57
round(4.5676,2)?
Answer: 4.57
divmod(10.5,5)
divmod(2.4,1.2)
Answer: (2.0, 0.5) (2.0, 0.0)
hex(15)
Answer: 0xf
d = {"john":40, "peter":45}
d["john"]
Answer: 40
a={1:"A",2:"B",3:"C"}
print(a.get(1,4))
Answer: A
total={}
def insert(items):
if items in total:
total[items] += 1
else:
total[items] = 1
insert('Apple')
insert('Ball')
insert('Apple')
print (len(total))
Answer: 2
a={}
a[2]=1
a[1]=[2,3,4]
print(a[1][1])
Answer: 3
x = 50
def func():
global x
print('x is', x)
x = 2
print('Changed global x to', x)
func()
print('Value of x is', x)
Answer: x is 50 Changed global x to 2 Value of x is 2
Answer: Method
Answer: Method
ef f(x, y, z): return x + y + z
f(2, 30, 400)
Answer: 432
def a(b):
b = b + [5]
c = [1, 2, 3, 4]
a(c)
print(len(c))
Answer: 5
d = {"john":40, "peter":45}
Answer: “john” and “peter”
d = {"john":40, "peter":45}
"john" in d
Answer: True
d1 = {"john":40, "peter":45}
d2 = {"john":466, "peter":45}
d1 == d2
Answer: False
d1 = {"john":40, "peter":45}
d2 = {"john":466, "peter":45}
d1 > d2
Answer: Error
d = {"john":40, "peter":45}
d["john"]
Answer: 40
Answer: del d[“john”]
Answer: len(d)