Questions Bank November 5, 2022 Comments Off on Questions Bank Questions Bank › Category: Python Essentials 2What is the expected result of the following snippet? try: raise Exception except: print(“c”) except BaseException: print(“a”) except Exception: print(“b”)OpenProgrammingAnswers asked 2 years ago • Python Essentials 2The following line of code: for line in open(‘text.txt’, ‘rt’):OpenProgrammingAnswers asked 2 years ago • Python Essentials 2What is the expected result of the following snippet? try: raise Exception except BaseException: print(“a”) except Exception: print(“b”) except: print(“c”)OpenProgrammingAnswers asked 2 years ago • Python Essentials 2If there is more than one except: branches after the try: clause, we can say that:OpenProgrammingAnswers asked 2 years ago • Python Essentials 2The following statement: from a.b import c causes the import of:OpenProgrammingAnswers asked 2 years ago • Python Essentials 2What will be the output of the following code, located in the p.py file? print(__name__)OpenProgrammingAnswers asked 2 years ago • Python Essentials 2Assuming that the following three files: a.py, b.py, and c.py reside in the same directory, what will be the output produced after running the c.py file? # file a.py print(“a”, end=”) # file b.py import a print(“b”, end=”) # file c.py print(“c”, end=”) import a import bOpenProgrammingAnswers asked 2 years ago • Python Essentials 2The compiled Python bytecode is stored in files which have their names ending with:OpenProgrammingAnswers asked 2 years ago • Python Essentials 2What output will appear after running the following snippet? import math print(dir(math))OpenProgrammingAnswers asked 2 years ago • Python Essentials 2Knowing that a function named fun() resides in a module named mod, and was imported using the following statement: from mod import fun Choose the right way to invoke the fun() function:OpenProgrammingAnswers asked 2 years ago • Python Essentials 2What is the expected result of the following code? import calendar c = calendar.Calendar() for weekday in c.iterweekdays(): print(weekday, end=” “)OpenProgrammingAnswers asked 2 years ago • Python Essentials 2Which program will produce the following output: Mo Tu We Th Fr Sa SuOpenProgrammingAnswers asked 2 years ago • Python Essentials 2What is the expected result of the following code? from datetime import datetime datetime = datetime(2019, 11, 27, 11, 27, 22) print(datetime.strftime(‘%y/%B/%d %H:%M:%S’))OpenProgrammingAnswers asked 2 years ago • Python Essentials 2What is the expected result of the following code? from datetime import date date_1 = date(1992, 1, 16) date_2 = date(1991, 2, 5) print(date_1 – date_2)OpenProgrammingAnswers asked 2 years ago • Python Essentials 2What is the expected result of the following code? import os os.mkdir(‘thumbnails’) os.chdir(‘thumbnails’) sizes = [‘small’, ‘medium’, ‘large’] for size in sizes: os.mkdir(size) print(os.listdir())OpenProgrammingAnswers asked 2 years ago • Python Essentials 2 Share Facebook Twitter Stumbleupon LinkedIn Pinterest