Python Summative 1 Flashcards

1
Q

One of the most popular programming languages

A

Python

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

The strengths of Python are the following:

A

Ease of Use
Readable
Complete
Cross-platform
Free

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

familiar constructs (loops, arrays, and so forth)

A

Ease of Use

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

easier it is to debug, maintain, and modify.

A

Readable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

its standard library comes with modules

A

Complete

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Windows, Mac, Linux, UNIX, and so on.

A

Cross-platform

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

developed under the open-source model

A

Free

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Many applications of Python

A

data science, scientific research, web development, etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

It is recommended to install Python that comes with the_______

A

Anaconda distribution.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Browser-based application that provides an environment for running and testing Python codes

A

Jupyter

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

ideal for documentation purposes which make both ease of sharing and code replicability possible

A

Jupyter

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

When launching Jupyter, notice that:

A

opens a browser window
command line interface (a.k.a. Jupyter Notebook server)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

This enables users to access Jupyter Notebook on their localhost

A

command line interface (a.k.a. Jupyter Notebook server)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

The other component of Jupyter is a dashboard which is accessible via a web browser

A

Dashboard

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

The URl is ________ which indicates its connection to the Jupyter Notebook Server.

A

localhost:8888

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

When commands were executed, it is actually executed in the _________

A

Notebook Server

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

The _____ displays files and folders that are in the home directory

A

dashboard

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Allows to create a folder to where Python notebooks were placed and then, proceed with creating a new Python notebook

A

Dashboard

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

It is a place to write in code or text

A

Cell

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

A cell is indicated by a _____, which is enclosed in a box

A

cell block

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Cell types:

A

code cell
markdown cell

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

The _______ is intended for typing in and run python codes.

A

code cell

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Printing hello world in a code cell requires ______

A

print()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

Markdown cell allows to create formatted text:

A

a header for a section by using #
header for a subsection by using ##
bold text by enclosing it in two asterisks

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

make sure to first select ______ from the pull-down list

A

‘Markdown’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

Jupyter functions in mainly two modes:

A

edit mode
command mode

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

is indicated by a green line in the leftmost part of an active cell

A

edit mode

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

In ______, we can type in our codes or markdown text

A

edit mode

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

is indicated by a blue line in the leftmost part of an active cell

A

Command mode

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

What is the output of the given code:
print (“Hello World!”)

A

Hello World!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

Jupyter assigns an _____ to remember which codes are executed first

A

execution number

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

This number is reflected in the rightmost part of executed code cells

A

Execution Numbers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

print()

A

print or output whatever is inside the open and close parentheses.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

“Hello world!” is an example of a data type called ____

A

string

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q

Any characters enclosed in _______ will be treated by Python as a string

A

quotations (either single or double quotation)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q

Python can be used to evaluate numerical expression in a code cell

A

Python as Calculator

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q

With print(), joining plain text with _______ is possible

A

values of numerical expression

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q

What is the output of the given code:
print(“16 x 24 = “, 16*24)

A

16 x 24 = 384

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
39
Q

Basic Numerical Operations

A

addition( + )
subtraction ( - )
multiplication ( * )
division ( / )
exponentiation (**)
modulo ( % )
integer division ( / /)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
40
Q

As in calculators, ______ is used for expressions with many operators

A

PEMDAS

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
41
Q

What is the output of the given code:
3+4*5

A

23

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
42
Q

What is the output of the given code:
(3*4)/(2**2 + 4/2)

A

2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
43
Q

an external python file that can be imported to a current python file.

A

Module

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
44
Q

In Jupyter, to have a quick view of the available functions in the module, type the ________

A

module name + dot + TAB

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
45
Q

These mathematical functions are executed via
___

A

math .function_name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
46
Q

The inputs to them are always placed ______ that are connected to the function name

A

inside of parentheses

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
47
Q

Aside from numerical expressions, Python can be used to compare values

A

Logical Operators

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
48
Q

What is the output of the given code:
5 > 4

A

TRUE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
49
Q

What is the output of the given code:
51.34 < 24.78

A

TRUE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
50
Q

What is the output of the given code:
(1+3) == (2 + 2)

A

TRUE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
51
Q

What is the output of the given code:
(1+3) != (2+2)

A

FALSE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
52
Q

The keywords ______ when dealing with multiple comparisons

A

and
or

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
53
Q

The keyword _____ is used to denote negation of a comparison result

A

not

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
54
Q

Boolean bool as data type can be ____

A

printed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
55
Q

What is the output of the given code:
(5>4) and (4<5)

A

TRUE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
56
Q

What is the output of the given code:
(5>4) or (5<4)

A

TRUE

57
Q

What is the output of the given code:
not 7 > 3

A

FALSE

58
Q

What is the output of the given code:
type(5>4)

A

bool

59
Q

What is the output of the given code:
type((1+3) > (2+5))

A

FALSE

60
Q

(72460*60) > 100000

A

TRUE

61
Q

A ______ is a named value (e.g. name, age, speed, area).

A

variable

62
Q

It gives a method to remember and reuse values and past calculations

A

Variables

63
Q

What is the output of the given code:
name = “Juan”
print(name, “is a student”)
print(name, “is 16 years old”)
print(name, “likes programming”)

A

Juan is a student
Juan is 16 years old
Juan likes programming

64
Q

What is the output of the given code:
age = 24
year = 2024 - age
print (“You are”, age, “years old)
print(“You were born in”, year)

A

You are 24 years old
You were born in 2000

65
Q

Jupyter makes it possible to see all the variables in the current notebook through the magic command ______.

A

%whos

66
Q

______specify the type of data that can be stored inside a variable

A

Data types

67
Q

Numeric Classes

A

int, float, complex

68
Q

holds numeric values

A

Numeric

69
Q

String Classes

A

str

70
Q

holds sequence of characters

A

String

71
Q

Sequence Classes

A

list
tuple
range

72
Q

holds collection of items

A

Sequence

73
Q

Mapping Classes

A

dict

74
Q

holds data in key-value pair form

A

Mapping

75
Q

Boolean Classes

A

bool

76
Q

holds either True or False

A

Boolean

77
Q

Set Classes

A

set
frozenset

78
Q

hold collection of unique items

A

Set
frozenset

79
Q

Use the command _____ to determine the type of data stored in variable

A

type()

80
Q

What is the output of the given code:
var1 = 15
print(var1, ‘is of type’, type(var1))
var2 = 93.0
print(var2, ‘is of type’, type(var2))
var3 = 61+4j
print(var3, ‘is of type’, type(var3))

A

15 is of type
93.0 is of type
(61+4j) is of type

81
Q

takes user input

A

input()

82
Q

converts a value to integer type

A

int()

83
Q

converts a value to floating point type

A

float()

84
Q

rounds a value to a specified precision

A

round()

85
Q

What is the output of the following:
y = 1.387668
round(y,2)

A

1.39

86
Q

What is the output of the given code:
user_in = input(“Enter a temperature in Celsius: “)
celsius = float(user_in)
fahrenheit = celsius * 9 / 5 + 32
print(“Temperature in Fahrenheit is “, fahrenheit)

A

Enter temperature in Celsius: 1
Tempereature in Fahrenheit is 33.8

87
Q

What is the output of the given code:
days = int(input(“Enter number of days: “))
seconds = days2460*60
print(“Equivalent number of seconds: “, seconds)

A

Enter number of days: 1
Equivalent number of seconds: 86400

88
Q

______ are code constructs that execute a block of code depending on a set of conditional criteria

A

Branching statements in Python

89
Q

These criteria are written as _______ and when satisfied, they execute a corresponding set of instructions

A

logical expressions,

90
Q

______ refers to the order of execution of computer instructions

A

Control flow

91
Q

The assessment of conditions at each branch in a computer program depends on evaluating logical statements, which yield Boolean values through comparison operations on Python’s primitive data types:
int (integer), float (floating-point), str (string), and bool (Boolean)

A

Comparison Operators

92
Q

An ______ statement in Python signifies an evaluation of its input logical expression

A

if

93
Q

The if statement’s code block will be executed only if the expression evaluates to a _____ value.

A

TRUE

94
Q

syntax for an if statement

A

if :
<code></code>

95
Q

A variant of the If statement is the ____ statement.

A

If-Else

96
Q

In this variant, a separate else code block is executed if the input logical expression of the if statement evaluates to False

A

If-Else

97
Q

The syntax for an If-Else statement is as follows:

A

if :

else:

98
Q

The _____ statement is another extension of the if statement.

A

if-elif-else

99
Q

It can provide a second if condition that will be evaluated if the first if condition evaluates to False

A

if-elif-else

100
Q

The syntax for an if-elif-else statement is as follows:

A

if :

elif :

else:

101
Q

The if code block will only execute if the if logical expression evaluates to ____. Else, the elif code block executes of the elif logical expression evaluates to _____. Else, the else code block executes by _____

A

TRUE
TRUE
Default

102
Q

One of the most common task when working on a collection of items is to perform sequence of instructions over each

A

Repetitions or Loop

103
Q

There are three main ways for Repeitions or Loop:

A

for loop
while loop
list comprehension

104
Q

is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set, or a string)

A

for loop

105
Q

A for loop is used for iterating over a sequence ______

A

(that is either a list, a tuple, a dictionary, a set, or a string)

106
Q

Syntax of for loop

A

for looping_variable in sequence:
code block

107
Q

Note:

Use of colon
Uniform indent for all lines
in code block

A

for loop

108
Q

What is the output of the following:
for n in range(5)
print(n)

A

0
1
2
3
4

109
Q

What is the output of the following:
word = “banana”
for i in range(len(word)):
n = i+1
print(n, word[:n])

A

1 b
2 ba
3 ban
4 bana
5 banan
6 banana

110
Q

When code block has multiple instructions, all lines must have the _____

A

same indent

111
Q

“What is the output of the following:
dict1 = {“one”:1, “two”:2, “three”:3}

for key, value in dict1.items():
print(key, value)

A

one 1
two 2
three 3

112
Q

A common way to access items of a dictionary is _____

A

using for loop

113
Q

The can execute a set of statements as long as a condition is true

A

while loop

114
Q

Syntax of while loop

A

while logical expression:
code block

115
Q

“What is the output of the following:
n = 0
while n<5:
print(n)
n=n+1

A

0
1
2
3
4

116
Q

To terminate an infinite loop, manually press the black square button in the menu indicating

A

‘kernel interruption.’

117
Q

A construct short, and elegant way for creating a list based on existing list

A

List Comprehension

118
Q

“What is the output of the following:
nums = [0, 1, 2, 3, 4]
nums_squared = [n**2 for n in nums]
nums_squared

A

[0, 1, 4, 9, 16]

119
Q

“What is the output of the following:
nums_square_even = [n**2 for n in nums if n%2 == 0]
nums_squared_even

A

[0, 4, 16]

120
Q

Which among these best describes the strength of Python in terms of readable?

A

easier it is to debug, maintain, and modify

121
Q

The ___________ is intended for typing in and run python codes.

A

code cell

122
Q

Which among these best describes the strength of Python in terms of ease of use?

A

familiar constructs (loops, arrays, and so forth)

123
Q

The edit and ______ mode are mainly two modes in Jupyter functions.

A

command

124
Q

Consider the following code segment:

sum=0.0

while true:

number=raw_input(“Enter a number: “)

if number==””:

   break

sum += float(number)

How many iterations does this loop perform?

A

none

125
Q

This command displays the datatype of a variable.

A

type

126
Q

Let x = 8 and y = 2. Write the values of the expression: x + y * 3

A

14

127
Q

Variables are important because it gives a method to remember and reuse values and __________calculations.

A

past

128
Q

Which of the following does not hold a collection?

A

set

129
Q

Complete the code to display the output below:

F

FE

FEU

FEUT

FEUTE

FEUTEC

FEUTECH

word = “FEUTECH”

for i in range(_______):

 n=i+1

 print(\_\_, word[:n])
A

len(word), i

130
Q

It is where functions and other resources are coded in.

A

module

131
Q

Let the variable x be “dog” and the variable y be “cat”. Write the code of this result: the dog chases the cat.

A

“the “ + x + “ chases the “ + y

132
Q

Let the variable x be “dog” and the variable y be “cat”. Write the value returned by Jupyter for this operation: x * 4.

A

dogdogdogdog

133
Q

Let x = 8 and y = 2. Write the values of the expression: (x + y) * 3

A

30

134
Q

The command _________ allows to display information of the recently used variables.

A

%whos

135
Q

Branching statements in Python, are code __________ that execute a block of code depending on a set of _______ criteria.

A

constructs, conditional

136
Q

The _______ loop can execute a set of statements as long as a condition is true.

A

while

137
Q

A datatype that holds numeric values?

A

complex

138
Q

Consider the following code segment:

count = 5

while count > 1:

print(count)

count -= 1

What is the output produced by this code?

A

5 4 3 2