Module 1: Python Introduction
Q1) Python Language was developed by:
Options:
A. James Gosling
B. Steve Jobs
C. Dennis Ritchie
D. Guido van Rossum
Q2) Python is _______ typed language.
Options:
A. Statically
B. Dynamically
C. English
D. None of the above
Q3) Which of the following is not the feature of Python?
Options:
A. Procedure Oriented
B. Object Oriented
C. Interpreted
D. Platform Dependent
Q4) What is the general extension of the python programs?
Options:
A. .pyc
B. .py
C. .python
D. .p
Q5) What command should be used to run python program assuming the name of program is
Hello.py ?
Options:
A. python Hello.py
B. py Hello.py
C. pyc Hello
D. python Hello
Module 2: Python Fundamentals
Q1) you develop a python application for your company. You want to add notes to your code so
other team members will understand it. What should you do?
Options:
A. Place the notes after the # sign on any line
B. Place the notes after the last line of code separated by a blank line
C. Place the notes before the first line of code separated by a blank line
D. Place the notes inside of parentheses on any time
Q2) You create a function to calculate the power of a number by using Python Practice Test. You
need to ensure that the function ¡s documented with comments. You create the following code.
Line numbers are included for reference only.
01 # The calc_power function calculates exponents
02 # x is the base
03 # y is the exponent
04 # The value of x raised to the y power is returned
05 def calc_power(x, y):
06 comment = “#Return the value”
07 return x**y # raise x to the y power
For each of the following statements, select Yes if the statement is true. Otherwise, select No.
Options: Yes No
Lines 01 through 04 will be ignored for syntax checking. 〇 〇
The pound sign (#) is optional for lines 02 and 03. 〇 〇
The string in line 06 will be interpreted as a comment. 〇 〇
Line 07 contains an inline comment. 〇 〇
Q3) Woodgrove Bank is migrating their legacy bank transaction code to Python Practice Test. You
have been hired to document the migrated code. Which documentation syntax is correct?
Options:
A. Returns the current balance of the bank account
def get_balance():
return balance
B. def get_balance():
/*Returns the current balance of the bank account*/
return balance
C. //Returns the current balance of the bank account
def get_balance():
return balance
D. def get_balance():
#Returns the current balance of the bank account
return balance
Q4) All keywords in Python are in
Options:
a) lower case
b) UPPER CASE
c) Capitalized
d) None of the above
Q5) Which of the following only contains keywords?
Options:
A. try & catch
B. and, or & in
C. while & do
D. if, elif , elseif & else
Q6) Which of the following does not contain keywords?
Options:
A. True & False
B. try, except & finally
C. is, not & or
D. break, continue & exit
Q7) Which of the following is invalid identifier rules? Select all that apply.
Options:
A. Name can contain $.
B. Name can begin with digit.
C. Keyword cannot be used as identifiers.
D. Names are case sensitive
Q8) Which of the following is an invalid variable?
Options:
a) my_string_1
b) 1st_string
c) repeat
d) _
Q9) What is the result of the following :
A) type(+1E10)
Options: 1) int 2) float 3) str 4)bool
B) type(5.0)
Options: 1) int 2) float 3) str 4)bool
C) type(“True”)
Options: 1) int 2) float 3) str 4)bool
D) type(False)
Options: 1) int 2) float 3) str 4)bool
Q10) You are writing a Python Program. The program collects customer data and stores it in a
database. You need to ensure that the program handles the data correctly so it can be stored in
the database correctly
age = 2; minor = False;
name = “Contoso”; weight = 123.5; zip = “81000”
What are the data types of the above declaration? Options:
A. int, bool, char[], float, char[]
B. int, bool, str, double and char
C. int, boolean, string, float and int
D. int, bool, str, float and str