Monty "Python" and the "Basics" Grail
I Can't Work in These Condition(al Statements)s
Data Structures (I couldn't think of a pun here, so just laugh...please)
Modules and Packages and No Bears, Oh My!
I/O, I/O, It's Off To Work We Go
100

Which is the special symbol used in python to add single-line comments?

#

100

careful = 0
second_chance = True
if careful:
          print('I got a second chance at this!')
elif second_chance:
          print('I am not being careful...')
else:
          print('I am being careful!')

I am not being careful...

100

How do you get the length of a list called listname?

len(listname)

100

Which methods would be used to generate random numbers in Python?

random.randint()

random.uniform()

uniform.random()

random.random()

random.randint()

random.uniform()

random.random()

100

Which of the following modes is most suitable for writing a binary file in Python? 

rb

ab

wb

write-binary

wb

200

What is the value of c?


a = 3
b = 5
c = a > b

False

200

staf = True
christal_ball = True
shield = True
sword = False
you_can_pass = staf and christal_ball or sword and shield

True

200

arr = ['Mug', 'Plate', 'Bowl', 'Saucer', 'Glass']
print(arr[-2])

Saucer

200

What does this code do?

x = random.randint(1,5)

producing a random integer between 1-5 (inclusive of 1 and 5)

200

Which of the following modes of file reading would be most appropriate for a program designed to update the contents of a .txt file without making any new deletion to the file.?

w
a
re
r

a for appending, adding (updating)

300

x = 5
y = 2

y -=1
print(x, y)

5, 1

300

def func(n):
    if n==1:
        return 1
    else:
        return(n+func(n-1))
print(func(4))

10

300

arr = ['Mug', 'Plate', 'Bowl', 'Saucer', 'Glass']
arr2 = arr[1:4]
print(arr2)

['Plate', 'Bowl', 'Saucer']

300

Suggest why a program may be broken down into individual functions.

a. Maintainability. Smaller, simpler functions are easier to maintain.

b. It helps to avoid syntax errors

c. Debugability. It's easier to debug simple functions than complex ones.

d. Non-Descriptive Naming of Variables.

a. Maintainability. Smaller, simpler functions are easier to maintain.

c. Debugability. It's easier to debug simple functions than complex ones.

300

The open() function opens a file in text format by default. Which mode opens the file in binary format for reading? 

rb

r

b

a

rb

400

Which of the following casts could result in a run time error?


An integer cast as a string

A float cast as a string

An int cast as a float

A string cast as an int

a string cast as an int

400

careful = 1
second_chance = True
if careful:
    print('I got a second chance at this!')
elif second_chance:
    print('I am not being careful...')
else:
    print('I am being careful!')

I got a second chance at this!

400

Which of the following methods allows to insert a specified value on a specified position? Use the example below for context


list_one = [1, 2, 3]
list_one.method(0, 0)
list_one = [0, 1, 2, 3]

insert()

400


Which of the following code snippets would be the correct way to import everything from a module

import randint as ra
from random import *
as ra import randint
from random as ra import randint

from random import *

400

A programmer wants to use simple and efficient tools for predictive data analysis that are used for Machine Learning. Suggest a suitable module or package that could be used to check for this task. 


os module

sys module

file module

scikit-learn

scikit-learn

500

An operation that modifies a variable without making a copy is known as ...

a. in-place operation

b. static typed operation

c. mutability operation

d. constant time operation

a. in-place operation

500

What is the value of the following code?

Reminder to myself: Conditional #1 picture

6

500

Which of the following shows the correct way to initialize a single dimension array?

a. arr = []

b. arr = ['Kan', 'Ryne', 'Em']

c. arr = {}

d. arr = [][]

 

a. arr = []

b. arr = ['Kan', 'Ryne', 'Em']

500

Which of the following best describes 'sklearn'? Is 'sklearn' a... 

a package

an environment

a module

a suite


a package

500

When creating a text file using the built-in open() function with 'a mode', what will occur if a file is written to a directory which contains a file having the same name?

A duplicate is created with a modified filename

An OS Error

The file is appended to, with the original contents saved

The file is overwritten  

The file is appended to, with the original contents saved

M
e
n
u