Questions Bank November 5, 2022 Comments Off on Questions Bank Questions Bank › Category: Python Essentials 2What is the expected result of the following code? import calendar calendar.setfirstweekday(calendar.SUNDAY) print(calendar.weekheader(3))OpenProgrammingAnswers asked 2 years ago • Python Essentials 2What is the expected result of the following code? from datetime import timedelta delta = timedelta(weeks = 1, days = 7, hours = 11) print(delta * 2)OpenProgrammingAnswers asked 2 years ago • Python Essentials 2What is the expected result of the following code? from datetime import datetime datetime_1 = datetime(2019, 11, 27, 11, 27, 22) datetime_2 = datetime(2019, 11, 27, 0, 0, 0) print(datetime_1 – datetime_2)OpenProgrammingAnswers asked 2 years ago • Python Essentials 2What information can be read using the uname function provided by the os module? (Select two answers)OpenProgrammingAnswers asked 2 years ago • Python Essentials 2What is the expected result of the following code? import os os.mkdir(‘pictures’) os.chdir(‘pictures’) print(os.getcwd())OpenProgrammingAnswers asked 2 years ago • Python Essentials 2Look at the code below: import random # # Insert lines of code here. # print(a, b, c) Which lines of code would you insert so that it is possible for the program to output the following result:OpenProgrammingAnswers asked 2 years ago • Python Essentials 2Look at the following code: numbers = [i*i for i in range(5)] # Insert line of code here. print(foo) Which line would you insert in order for the program to produce the expected output? Output[1, 9]OpenProgrammingAnswers asked 2 years ago • Python Essentials 2Look at the following code: numbers = [0, 2, 7, 9, 10] # Insert line of code here. print(list(foo)) Which line would you insert in order for the program to produce the expected output? Output[0, 2, 7, 9, 10]OpenProgrammingAnswers asked 2 years ago • Python Essentials 2Which pip command would you use to uninstall a previously installed package?OpenProgrammingAnswers asked 2 years ago • Python Essentials 2Which of the following commands would you use to check pip’s version? (Select two answers)OpenProgrammingAnswers asked 2 years ago • Python Essentials 2If you want to fill a byte array with data read in from a stream, which method can you use?OpenProgrammingAnswers asked 2 years ago • Python Essentials 2Assuming that the open() invocation has gone successfully, the following snippet: for x in open(‘file’, ‘rt’): print(x) will:OpenProgrammingAnswers asked 2 years ago • Python Essentials 2If s is a stream opened in read mode, the following line: q = s.read(1) will read:OpenProgrammingAnswers asked 2 years ago • Python Essentials 2What is the expected result of executing the following code? def o(p): def q(): return ‘*’ * p return q r = o(1) s = o(2) print(r() + s())OpenProgrammingAnswers asked 2 years ago • Python Essentials 2What is the expected result of executing the following code? class I: def __init__(self): self.s = ‘abc’ self.i = 0 def __iter__(self): return self def __next__(self): if self.i == len(self.s): raise StopIteration v = self.s[self.i] self.i += 1 return v for x in I(): print(x, end=”)OpenProgrammingAnswers asked 2 years ago • Python Essentials 2 Share Facebook Twitter Stumbleupon LinkedIn Pinterest