What will be the output of the following Python code snippet?
a={1:"A",2:"B",3:"C"} print(a.get(3))
a={1:"A",2:"B",3:"C"} a.setdefault(4,"D") print(a)
What will be the output of the following Python code?
a={1:"A",2:"B",3:"C"} b={4:"D",5:"E"} a.update(b) print(a)
a={1:"A",2:"B",3:"C"} b=a.copy() b[2]="D" print(a)
a={1:"A",2:"B",3:"C"} a.clear() print(a)
a={1:5,2:3,3:4} a.pop(3) print(a)
a={1:"A",2:"B",3:"C"} for i in a: print(i,end=" ")
a={1:"A",2:"B",3:"C"} print(a.items())
>>> a={1:"A",2:"B",3:"C"} >>> del 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))
a = {} a[1] = 1 a['1'] = 2 a[1]=a[1]+1 count = 0 for i in a: count += a[i] print(count)
numbers = {} letters = {} comb = {} numbers[1] = 56 numbers[3] = 7 letters[4] = 'B' comb['Numbers'] = numbers comb['Letters'] = letters print(comb)
test = {1:'A', 2:'B', 3:'C'} test = {} print(len(test))
test = {1:'A', 2:'B', 3:'C'} del test[1] test[1] = 'D' del test[2] print(len(test))
a = {} a[1] = 1 a['1'] = 2 a[1.0]=4 count = 0 for i in a: count += a[i] print(count) print(a)
a={} a['a']=1 a['b']=[2,3,4] print(a)
count={} count[(1,2,4)] = 5 count[(4,2,1)] = 7 count[(1,2)] = 6 count[(4,2,1)] = 2 tot = 0 for i in count: tot=tot+count[i] print(len(count)+tot)
a={} a[2]=1 a[1]=[2,3,4] print(a[1][1])
a={'B':5,'A':9,'C':7} print(sorted(a))
a=dict() print(a[1])
What will be the output of the following Python expression?
print(round(4.576))
print(round(4.5676,2))
What will be the output of the following Python function?
import math print(abs(math.sqrt(25)))
sum(2,4,6) sum([1,2,3])
min(max(False,-3,-4), 2,7)
len(["hello",2, 4, 6])
def foo(k): k[0] = 1 q = [0] foo(q) print(q)
def foo(fname, val): print(fname(val)) foo(max, [1, 2, 3]) foo(min, [1, 2, 3])
def foo(): return total + 1 total = 0 print(foo())
def foo(): total += 1 return total total = 0 print(foo())
def foo(x): x = ['def', 'abc'] return id(x) q = ['abc', 'def'] print(id(q) == foo(q))
def foo(x): x[0] = ['def'] x[1] = ['abc'] return id(x) q = ['abc', 'def'] print(id(q) == foo(q))
def f1(a,b=[]): b.append(a) return b print(f1(2,[3,4]))
import datetime d=datetime.date(2017,6,18) print(d)
What will be the output of the following Python code if the system date is 18th August, 2016?
import datetime d=datetime.date.today() print(d.month)
What will be the output of the following Python code if the system date is 18th June, 2017 (Sunday)?
import datetime tday=datetime.date.today() print(tday)
import datetime tday=datetime.date.today() print(tday.weekday())
What will be the output of the following Python code if the system date is 21st June, 2017 (Wednesday)?
import datetime tday=datetime.date.today() print(tday.isoweekday())
What will be the output of the following Python code if the system date is: 6/19/2017
import datetime tday=datetime.date.today() tdelta=datetime.timedelta(days=10) print(tday+tdelta)
import time print(time.asctime())
What will be the output of the following Python function, assuming that the random module has already been imported?
import random random.uniform(3,4)
What will be the output of the following Python function if the random module has already been imported?
import random print(random.randint(3.5,7))
import random print(random.randrange(0,91,5))
Which can be the output of the following Python code?
import random print(random.randrange(1,100,10))