WorksheetsPrinciples of Programming Set 3
Total questions: 40
Worksheet time: 20mins
Name
Class
Date
1.
In Python, what defines code blocks?
a)
Semicolons
b)
Curly braces
c)
Indentation
d)
Brackets
e)
Parentheses
2.
What does the type() function return?
a)
Data value
b)
Class type
c)
Function address
d)
Memory size
e)
Scope
3.
Which language fits under the 5GL category?
a)
Java
b)
Python
c)
Prolog
d)
C++
e)
SQL
4.
What makes Python suitable for many domains?
a)
Small size
b)
No indentation
c)
Robust libraries
d)
Built-in assembly
e)
Single paradigm
5.
What is GitHub primarily used for?
a)
AI generation
b)
Hosting repositories
c)
Creating GUIs
d)
Writing markdown
e)
Editing images
6.
What does the continue statement do in a loop?
a)
Ends the loop
b)
Skips current iteration
c)
Returns a value
d)
Restarts the loop
e)
Does nothing
7.
What language is typically used for text formatting in notebooks?
a)
LaTeX
b)
XML
c)
HTML
d)
Markdown
e)
Bash
8.
Which of these is an example of a cloud-based notebook?
a)
VS Code
b)
Eclipse
c)
Google Colab
d)
Spyder
e)
Atom
9.
Which of these environments supports live markdown rendering and code execution?
a)
Google Docs
b)
Sublime Text
c)
Jupyter Notebook
d)
GitHub
e)
Android Studio
10.
Which keyword is used to define a class in Python?
a)
object
b)
struct
c)
class
d)
type
e)
define
11.
Which of these is a valid list comprehension?
a)
list = for i in 5 print(i)
b)
[i for i in range(5)]
c)
(i for i in range(5))
d)
{i: i for i in range(5)}
e)
def list[i]
12.
Python in its procedural form follows which paradigm?
a)
Functional
b)
Object-Oriented
c)
Declarative
d)
Imperative
e)
Logical
13.
Which method is used to read input from the user?
a)
input()
b)
scan()
c)
read()
d)
get()
e)
cin
14.
What does a diamond symbol represent in a flowchart?
a)
Start
b)
End
c)
Input
d)
Decision
e)
Process
15.
Which of these is primarily used for scientific programming in Python?
a)
Eclipse
b)
PyCharm
c)
Spyder
d)
IntelliJ
e)
Brackets
16.
Why is indentation important in Python?
a)
For loops only
b)
For memory
c)
For block definition
d)
For speed
e)
To confuse users
17.
What is a REPL primarily used for?
a)
Data storage
b)
OS control
c)
Interactive coding
d)
File deletion
e)
Kernel operations
18.
In which section would you define functions in a Python program?
a)
Imports
b)
Main code block
c)
Constants section
d)
Function definitions
e)
Header comments
19.
What happens if indentation is not consistent in Python?
a)
Nothing
b)
SyntaxError
c)
IndentationError
d)
Warning
e)
Passes silently
20.
What is the main role of a terminal emulator today?
a)
Compile code
b)
Simulate GUI
c)
Emulate old physical terminals
d)
Manage databases
e)
Render 3D
21.
What is a benefit of using indentation for code blocks?
a)
Harder debugging
b)
Compact syntax
c)
Enhanced readability
d)
More typing
e)
Manual parsing
22.
Which feature allows notebooks to embed documentation with equations?
a)
Shell access
b)
Markdown support
c)
Debugger
d)
Plugin engine
e)
Linter
23.
Which version control tool is most commonly used with GitHub?
a)
SVN
b)
CVS
c)
Git
d)
Mercurial
e)
Docker
24.
What does the Zen of Python emphasize most?
a)
Braces over indentation
b)
Speed over clarity
c)
Explicit is better than implicit
d)
Use of semicolons
e)
Performance over readability
25.
Which module is used for abstraction in Python?
a)
functools
b)
abc
c)
collections
d)
os
e)
struct
26.
What Python structure ensures modular execution?
a)
main()
b)
try...catch
c)
if __name__ == "__main__"
d)
loop
e)
for
27.
What is the purpose of the shebang line in a Python script?
a)
To specify encoding
b)
To print output
c)
To define interpreter path
d)
To import modules
e)
To handle exceptions
28.
What is the main difference between a shell and a REPL?
a)
REPL uses colors
b)
Shell is web-based
c)
Shell interacts with OS, REPL runs code
d)
REPL lacks input
e)
Shell uses GUIs
29.
What is code collaboration?
a)
Solo editing
b)
Hardware setup
c)
Developers working on the same code
d)
Encrypting files
e)
Compiler optimization
30.
What is the primary benefit of transpilation?
a)
Changing bytecode into machine code
b)
Reducing memory consumption
c)
Converting code to a high-level language
d)
Running code on different platforms
e)
Executing binary files
31.
Which feature is commonly found in IDEs but not in basic text editors?
a)
Syntax highlighting
b)
Markdown support
c)
Version control integration
d)
Basic editing
e)
File saving
32.
What is the primary role of an interpreter?
a)
To translate source code into bytecode
b)
To translate and immediately execute code line-by-line
c)
To generate machine code from source code
d)
To optimize compiled code for performance
33.
What best explains Python’s growth in data science?
a)
High cost
b)
Simplicity & libraries
c)
AI-only support
d)
Hardware focus
e)
GUI design
34.
What does a JIT compiler do to improve performance?
a)
Compiles all code before execution
b)
Deletes unused code
c)
Translates machine code to bytecode
d)
Compiles hot code during runtime
e)
Compresses source code
35.
What is the output? print(10 // 3)
a)
3.33
b)
3
c)
4
d)
10
36.
What is wrong with this code? my_list = [1, 2, 3]; my_list.append = 4
a)
Nothing
b)
append should be called
c)
List can’t be modified
d)
Index error
e)
Syntax error
37.
Which of the following best describes a command-line interface?
a)
GUI interface for editors
b)
Menu-driven program
c)
Text-based interface for commands
d)
IDE for terminals
e)
Dashboard view of the OS
38.
Which type of collaboration allows editing and debugging together?
a)
Pair programming
b)
Real-time collaboration
c)
Git pull
d)
Merge conflict
e)
UML modeling
39.
Which of these is not required in a Python program?
a)
Imports
b)
Functions
c)
Constants
d)
Shebang line
e)
Valid statement
40.
Which notebook interface is specifically designed for big data and Spark?
a)
Jupyter
b)
Colab
c)
Databricks
d)
Spyder
e)
RStudio
100 %
