What would you use instead of XXX if you want to check whether a certain ‘ key' exists in a dictionary called diet? (Select two answers)
What would you use instead of XXX if you want to check whether a certain ‘ key' exists in a dictionary called diet? (Select two answers) II if XXX: print ("Key exists")A . 'key' in dietB . diet['key'] != NoneC . diet.exists('key')D . 'key' in diet.keys()View AnswerAnswer: B,D
What is the expected behavior of the following code?
What is the expected behavior of the following code? A . it outputs 6B . it outputs 1C . it outputs 3D . it raises an exceptionView AnswerAnswer: A
What is the expected output of the following code if existing_file is the name of a file located inside the working directory?
What is the expected output of the following code if existing_file is the name of a file located inside the working directory? A . 1 2B . 1 2 3C . 1 3D . 2 3View AnswerAnswer: C
A file name like this one below says mat: (select three answers)
A file name like this one below says mat: (select three answers) services. cpython-36.pycA . the interpreter used to generate the file is version 3.6B . it has been produced by CPythonC . it is the 36th version of the fileD . the file comes from the services . py...
Which of the following snippets will let you access the variable?
A Python module named pymod.py contains a variable named pyvar. Which of the following snippets will let you access the variable? (Select two answers)A . import pyvar from pymod pyvar = 1B . from pymod import pyvar = 1C . from pymod import pyvar pyvar ()D . import pymod pymod.pyvar...
What is the expected behavior of the following code?
What is the expected behavior of the following code? A . it outputs errorB . it outputs list assignment index out of rangeC . the code is erroneous and it will not executeD . it outputs <class ' IndexError’ >View AnswerAnswer: B
What is the expected output of the following code if the file named existing_text_file is a non-zero length text file located inside the working directory?
What is the expected output of the following code if the file named existing_text_file is a non-zero length text file located inside the working directory? A . the length of the first line from the fileB . -1C . the number of lines contained inside the fileD . the length...
What can you deduce from the following statement? (Select two answers)
What can you deduce from the following statement? (Select two answers) str = open('file.txt', "rt")A . str is a string read in from the file named file.txtB . a newlina character translation will be performed during the readsC . if file. txt does not exist, it will be createdD ....
Which of the following expression evaluate to True? (Select two answers)
Which of the following expression evaluate to True? (Select two answers)A . 'in not' in 'not'B . 'in' in 'Thames'C . 't' . upper ( ) in 'Thames'D . 'in' in 'in'View AnswerAnswer: C,D
What will be the value of the i variable when the while e loop finishes its execution?
What will be the value of the i variable when the while e loop finishes its execution? A . 1B . 0C . 2D . the variable becomes unavailableView AnswerAnswer: A