What will be the output of the following Python code snippet? d1 = {"john":40, "peter":45} d2 = {"john":466, "peter":45} d1 > d2 a) True b) False c) Error d) None

1 Answer

Answer :

Answer: c Explanation: Arithmetic > operator cannot be used with dictionaries.

Related questions

Description : What will be the output of the following Python code snippet? d1 = {"john":40, "peter":45} d2 = {"john":466, "peter":45} d1 == d2 a) True b) False c) None d) Error

Last Answer : Answer: b Explanation: If d2 was initialized as d2 = d1 the answer would be true.

Description : What will be the output of the following Python code snippet? d = {"john":40, "peter":45} "john" in d a) True b) False c) None d) Error

Last Answer : Answer: a Explanation: In can be used to check if the key is int dictionary.

Description : What will be the output? d1 = {"john":40, "peter":45} d2 = {"john":466, "peter":45} d1 > d2 a) True b) False c) Error d) None

Last Answer : c) Error

Description : What will be the output? d1 = {"john":40, "peter":45} Page No 40 d2 = {"john":466, "peter":45} d1 == d2 a) True b) False c) None d) Error

Last Answer : b) False

Description : What will be the output of the following Python code snippet? d = {"john":40, "peter":45} a) “john”, 40, 45, and “peter” b) “john” and “peter” c) 40 and 45 d) d = (40:”john”, 45:”peter”)

Last Answer : Answer: b Explanation: Dictionaries appear in the form of keys and values.

Description : What will be the output of the following Python code? d = {"john":40, "peter":45} d["john"] a) 40 b) 45 c) “john” d) “peter”

Last Answer : Answer: a Explanation: Execute in the shell to verify.

Description : Which of the following statements create a dictionary? a) d = {} b) d = {“john”:40, “peter”:45} c) d = {40:”john”, 45:”peter”} d) All of the mentioned

Last Answer : A

Description : What will be the output of the following Python code? >>> a={5,4}>>> b={1,2,4,5}>>> a

Last Answer : Answer: b Explanation: a

Description : What will be the output of the following Python code? >>> a={4,5,6}>>> b={2,8,6}>>> a+b a) {4,5,6,2,8} b) {4,5,6,2,8,6} c) Error as unsupported operand type for sets d) Error as the duplicate item 6 is present in both sets

Last Answer : Answer: c Explanation: Execute in python shell to verify.

Description : What will be the output of the following Python code? nums = set([1,1,2,3,3,3,4,4])print(len(nums)) a) 7 b) Error, invalid syntax for formation of set c) 4 d) 8

Last Answer : Answer: c Explanation: A set doesn’t have duplicate items.

Description : What will be the output? d = {"john":40, "peter":45} "john" in d a) True b) False c) None d) Error

Last Answer : a) True

Description : What will be the output of the following Python code? >>>t = (1, 2) >>>2 * t a) (1, 2, 1, 2) b) [1, 2, 1, 2] c) (1, 1, 2, 2) d) [1, 1, 2, 2]

Last Answer : Answer: a Explanation: * operator concatenates tuple.

Description : What will be the output of the following Python code? >>>t = (1, 2, 4, 3, 8, 9) >>>[t[i] for i in range(0, len(t), 2)] a) [2, 3, 9] b) [1, 2, 4, 3, 8, 9] c) [1, 4, 8] d) (1, 4, 8)

Last Answer : Answer: c Explanation: Execute in the shell to verify.

Description : What will be the output of the following Python code? >>>t=(1,2,4,3) >>>t[1:-1] a) (1, 2) b) (1, 2, 4) c) (2, 4) d) (2, 4, 3)

Last Answer : Answer will be (2,)

Description : What will be the output of the following Python code? >>>t=(1,2,4,3) >>>t[1:3] a) (1, 2) b) (1, 2, 4) c) (2, 4) d) (2, 4, 3)

Last Answer : Answer: c Explanation: Slicing in tuples takes place just as it does in strings.

Description : What is the output of print 0.1 + 0.2 == 0.3? a) True b) False c) Machine dependent d) Error

Last Answer : Answer: b Explanation: Neither of 0.1, 0.2 and 0.3 can be represented accurately in binary. The round off errors from 0.1 and 0.2 accumulate and hence there is a difference of 5.5511e-17 between (0.1 + 0.2) and 0.3.

Description : Suppose d = { john :40, peter :45}, what happens when we try to retrieve a value using the expression d[ susan ]? a) Since susan is not a value in the set, Python raises a KeyError ... Python raises a KeyError exception d) Since susan is not a key in the set, Python raises a syntax error

Last Answer : c) Since “susan” is not a key in the set, Python raises a KeyError exception

Description : Which of the following is true for variable names in Python? a) unlimited length b) all private members must have leading and trailing underscores c) underscore and ampersand are the only two special characters allowed d) none of the mentioned

Last Answer : Answer: a Explanation: Variable names can be of any length.

Description : If a={5,6,7,8}, which of the following statements is false? a) print(len(a)) b) print(min(a)) c) a.remove(5) d) a[2]=45

Last Answer : Answer: d Explanation: The members of a set can be accessed by their index values since the elements of the set are unordered.

Description : What is the take away from this python, and ventilation system related story?

Last Answer : answer:I am suspicious of the story until the autopsy results are available. Snakes don't tend to catch and release - I'm surprised it didn't ingest the child. Snakes ... ineffective. Regulations allow the control and monitoring of populations, and hopefully fewer underground/illegal ownership.

Description : What's more powerful, JavaScript or Python?

Last Answer : Python is server side. You use python to output HTML/CSS/Javascript that the browser interprets. Your browser doesn’t know what Python is.

Description : What are the differences between Perl, PHP, and Python?

Last Answer : Um, i unfortunately cannot answer this question, but I have to ask: why the NSFW tag?

Description : What is the best platform for buildinga socail site; Python, ROR, or ASP.Net?

Last Answer : I would probably go with Django if you are down with Python. I hate RoR with a passion. Have you looked at any of the PHP based MVC frameworks? I’m fond of CakePHP myself. And I know lots of people like to hate on PHP, but it is fast and it works.

Description : So why are there so few web hosting services that offer Python support?

Last Answer : Virtual hosting and colocated hosting are so cheap now that shared-server web hosting services have to cut back on services. So shared-server web hosts focus on the features that the cheapskates of the ... -rate shared-server web hosts, but you'll actually be able to install the software you need.

Description : Is the Python Imaging Library not available on PyPI, or am I missing something?

Last Answer : Hm, forcing it to find-links seems to be working: easy_install -f http://www.pythonware.com/products/pil/ Imaging Got a heap of warnings along the way though. I’ll see how it turns out.

Description : How to write a Python program (i)to calculate area of a circle and (ii)to find if a given number is even or odd. -Python

Last Answer : (i) # 1.Circle pi = 3.14 r = int(input("Please enter the Radius of the circle:")) area = pi*r*r print("Area of the circle is" + str(area) + "sq ms") (ii) # 2. Odd Number & Even Number Number = int( ... Number % 2 == 0): print("This is an Even Number") else: print("It's an Odd Number")

Description : Write a Python statement for assigning a string have a good day to a variable good -Python

Last Answer : good = "have a good day" Here good is the variable name and have a good day is a value in string (text)

Description : List out the different operators used in Python. What is the difference between operant’s and operators explain with example. -Python

Last Answer : Python divides the operators in the following groups: Arithmetic operators Assignment operators Comparison operators Logical operators Identity operators Membership operators Bitwise operators For students of class 9th : Arithmetic operators Assignment ... the right x >= y = x >>= 5 x = x >> 5

Description : How to write python statement for assigning a value 55.5 to a variable maths -Python

Last Answer : variable name = "maths" value = "55.5" maths = 55.5

Description : What is a program ? -Python

Last Answer : Program is a set of instructions to perform a specific task using any programming language.

Description : how to run a python program in visual studio ? -Python

Last Answer : By creating a file It's simple to run anyfilename.py with Python. Just click the Run Python File in Terminal play button in the top-right side of the editor. Your program will start executing. ... Run Selection/Line in Python Terminal. This command is convenient for testing just a part of a file

Description : How can we execute Python Programs in Windows 10? -Python

Last Answer : If you have made an python program or u want to make it and execute it the you can do it by various methods : 1) With an IDE : => What is IDE IDE, or Integrated Development Environment, is a software ... into the python shell ... you can start typing your code .... try to type print("Hello World!")

Description : What is Python?

Last Answer : Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming. Python's elegant syntax ... an ideal language for scripting and rapid application development in many areas on most platforms.

Description : Which of the following is a Python tuple? a) [1, 2, 3] b) (1, 2, 3) c) {1, 2, 3} d) {}

Last Answer : Answer: b Explanation: Tuples are represented with round brackets.

Description : All keywords in Python are in _________ a) lower case b) UPPER CASE c) Capitalized d) None of the mentioned

Last Answer : Answer: d Explanation: True, False and None are capitalized while the others are in lower case.

Description : Is Python case sensitive when dealing with identifiers? a) yes b) no c) machine dependent d) none of the mentioned

Last Answer : Answer: a Explanation: Case is always significant.

Description : What will be the output? d = {"john":40, "peter":45} print(list(d.keys())) a) [“john”, “peter”]. b) [“john”:40, “peter”:45]. c) (“john”, “peter”) d) (“john”:40, “peter”:45)

Last Answer : a) [“john”, “peter”].

Description : What is the output? d = {"john":40, "peter":45} d["john"] a) 40 b) 45 c) “john” d) “peter”

Last Answer : a) 40

Description : What will be the output? d = {"john":40, "peter":45} d["john"] a) 40 b) 45 c) “john” d) “peter”

Last Answer : a) 40

Description : Read the code shown below carefully and pick out the keys? d = {"john":40, "peter":45} a) “john”, 40, 45, and “peter” b) “john” and “peter” c) 40 and 45 d) d = (40:”john”, 45:”peter”)

Last Answer : b) “john” and “peter”

Description : What is the result of cmp(3, 1)? a) 1 b) 0 c) True d) False

Last Answer : Answer: a Explanation: cmp(x, y) returns 1 if x > y, 0 if x == y and -1 if x < y

Description : If a={5,6,7}, what happens when a.add(5) is executed? a) a={5,5,6,7} b) a={5,6,7} c) Error as there is no add function for set data type d) Error as 5 already exists in the set

Last Answer : Answer: b Explanation: There exists add method for set data type. However 5 isn’t added again as set consists of only non-duplicate elements and 5 already exists in the set. Execute in python shell to verify.

Description : Suppose t = (1, 2, 4, 3), which of the following is incorrect? a) print(t[3]) b) t[3] = 45 c) print(max(t)) d) print(len(t))

Last Answer : d) print(len(t)) is incorrect. In python, len(t) is a built-in function that returns the number of items in the tuple t. Since t contains 4 items, len(t) would correctly return 4. a) print(t[ ... of tuple. c) print(max(t)) is correct, it will return the maximum element of tuple which is 4.

Description : Which of the following statements is TRUE? D1: The decomposition of the schema R(A,B,C) into R1(A,B) and R2(A,C) is always lossless. D2: The decomposition of the schema R(A,B,C,D,E) having AD→B, C→DE, B→AE, AE→C ... ,D,E) is lossless. (A) Both D1 and D2 (B) Neither D1 and D2 (C) Only D1 (D) Only D2

Last Answer : (D) Only D2

Description : Suppose d = {“john”:40, “peter”:45}. To obtain the number of entries in dictionary which command do we use? a) d.size() b) len(d) c) size(d) d) d.len()

Last Answer : b) len(d)

Description : Suppose d = {“john”:40, “peter”:45}, to delete the entry for “john” what command do we use a) d.delete(“john”:40) b) d.delete(“john”) c) del d[“john”]. d) del d(“john”:40)

Last Answer : c) del d[“john”].

Description : Which of the following statements create a dictionary? a) d = {} b) d = {“john”:40, “peter”:45} c) d = {40:”john”, 45:”peter”} d) All of the mentioned

Last Answer : d) All of the mentioned

Description : A particle experiences constant acceleration for 20 seconds after starting from rest. If it travels a distance D1 in the first 10 seconds and distance D2 in the next 10 seconds then, (a) D2 = D1 (b) D2 = 2D1 (c) D2 = 3D1 (d) D2 = 4D1 -Science

Last Answer : (c) is the answer

Description : In a rhombus if d1 = 16 cm, d2 = 12 cm, then the length of the side of the rhombus is (a) 8 cm (b) 9 cm (c) 10 cm (d) 12 cm

Last Answer : (c) 10 cm

Description : A compound pipe of diameter d1, d2 and d3 having lengths l1, l2 and l3 is to be replaced by an equivalent pipe of uniform diameter d and of the same length (l) as that of the compound pipe. The size of the equivalent pipe is given by (A) l/d² = + + (B) l/d³ = + ) + (C) = + + (D)

Last Answer : Answer: Option D