Final Flashcards
The primary purpose of the symbol table during lexical analysis is to store information about identifiers such as variable names
True of False
True
Regular grammars are a type of formal grammar that generate regular languages. They have production rules of the form A → αB or A → α, where A and B are non-terminal symbols, and α is a string of terminal symbols.
True of False
True
Strength reduction is a compiler optimization technique that involves replacing less expensive operations with expensive ones.
True or False
False
A deterministic finite automaton M is a 5-tuple, (Q, Σ, δ, q0, F).
True or False
True
In short, the parse tree is generated by the syntax analyzer.
True or False
True
True or False
In Python structure, a statement indentation does not matter
False
def calculate_sum(a, b=5, c=10):
return a + b + c
result = calculate_sum(2)
The value of result after executing the above code is _______
22
What does the socket.AF_INET parameter represent in the socket.socket() constructor?
Socket address family for IPv4
try:
num = int(“abc”)
except ValueError:
num = 0
finally:
num += 1
print(num)
What is the output of this code?
2
Which module is used for network programming in Python?
socket
All variables in Python must be explicitly declared with a data type
False
Convert all characters to upper case
str.upper()
Add an element to the end of the list
list.append()
Opens a file for reading or writing
open()
Reading data from a file in python
readline()
Set the maximum number of queued connections
socket.listen()
In a DFA state diagram, circles represent states, and arrows (transitions) indicate the transitions between states based on input symbols.
True or false
True
Optimization of a program that works within a single basic block of code is called .
local transformation
Which gcc compiler optimization flag optimizes the generated code for both size and speed?
-O2
The grammar of the programming (i.e., grammatical errors) is checked at phase of the compiler
syntax analysis
Which of the following is the correct extension of the Python file?
.py
What is the order of precedence in python?
Parentheses, Exponential, Multiplication, Division, Addition, Subtraction
What will be the output of the following Python function?
max(max(True,-3,-4), 2 ,0 )
2
What will be the output of the following Python code snippet?
def foo(x):
x[0] = [‘def’]
x[1] = [‘abc’]
return id(x)
q = [‘abc’, ‘def’]
print(id(q) == foo(q))
Error
What will be the output of the following Python code?
> > > list1 = [1, 3]
list2 = list1
list1[0] = 4
print(list2)
[4,3]
What will be the output of the following Python code?
x = ‘abcd’
for i in range(len(x)):
print(i)
0 1 2 3
What will be the output of the following Python expression?
> > > from math import *
ceil(4.576)
5
What will be the output of the following Python code?
> > > example = “snow world”
example[3] = ‘s’
print(example)
Error