Python Programming

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

The bytecode is a low-level platform-independent representation of the source code with ____________ format, however, it is not the binary machine code and cannot be run by the target machine directly.

.pyc

In object-oriented programming, __________ is the process of creating objects that inherit properties and behaviors from a class.

Inheritance

6. A UI object is responsible for presenting a graphical or textual _________ to the user and handling user _____________.

Interface, Interaction

A UI object is responsible for presenting a graphical or textual __________ to the user and handling user __________.

Interface/ Interactions

Python is usually called an _______________ language, however, it combines compiling and interpreting.

Interpreted

however, it is not the binary machine code and cannot be run by the target machine directly. In fact, it is a set of instructions for a virtual machine which is called the Python _________________.

Interpreter

In object-oriented programming, an __________ is a blueprint for creating objects. a) Attribute b) Method c) Class d) Instance

c) Class

2. What is the primary responsibility of a UI object in an object-oriented model? a) Managing database connections b) Processing CRUD operations c) Handling user interactions and displaying information d) Defining data attributes

c) Handling user interactions and displaying information

What is the primary responsibility of a UI object in an object-oriented model? ________ a) Managing database connections b) Processing CRUD operations c) Handling user interactions and displaying information d) Defining data attributes

c) Handling user interactions and displaying information

4. The database object in an object-oriented model is responsible for: a) Rendering user interfaces b) Handling user input validation c) Interacting with a database, including querying and updating data d) Performing complex mathematical calculations

c) Interacting with a database, including querying and updating data

To indicate a block of code in Python, you must ____________ each line of the block by thesame whitespace.

Indent

The ________________ statement is used to skip the current iteration of a loop and proceed tothe next iteration.

"continue"

In Python, to create a child class that inherits from a parent class, you use the keyword__________.

'class'

When we execute a Python source code with extension _______________, it first compiles it into a bytecode.

.py

Which of the following operators is used for exponentiation in Python? _____________ a) ** b) ^ c) * d) /

A) **

What does the ^ operator do in Python? _______________ a) Bitwise XOR b) Bitwise OR c) Bitwise AND d) Exponentiation

A) Bitwise XOR

Which operator is used for string concatenation in Python? _____________ a) + b) - c) * d) /

A)+

What is the result of 5 & 3 in binary? ________________ a) 1 b) 3 c) 5 d) 7

A)1

The >> operator in Python is used for: _____________ a) Logical AND b) Right shift c) Exponentiation d) Floor division

B) Right shift

Which one is not a data type for variable in Python? ________ a) String b) List c) Set d) Dictionary

C) Set

What is the result of 10 | 6 in binary? _____________ a) 2 b) 6 c) 14 d) 10

C)14

The and operator in Python is used for _______________ logical operations.

Combining or Conjunction

Which operator is used for checking if a value is not in a list or sequence in Python?____________ a) != b) is not c) <> d) not in

D) not in

7. The primary focus of a CRUD object is to facilitate Create, Read, Update, and Delete operations on ______________.

Data

The == operator is used for checking _______________ between two values.

Equality

06. In Python, an interface defines a set of _______________ that must be implemented by any class that claims to implement the interface.

Methods

A well-structured CRUD object can significantly enhance the __________ and maintain ability of an application's data operations.

Modularity

8. Which method is used to override the string representation of an object in Python? a) toString() b)str c) print() d) display0

b)str

The double underscore prefix before an attribute or method name in Python is used to indicate__________ access.

Private

In Python, the default access modifier for class members is __________.

Public

Is Python code compiled or interpreted? __________

Python code is both compiled and interpreted

010. The purpose of an interface in Python is to establish a __________ contract for classes that implement it

behavioral

Q3. In Python, an interface defines a set of that must be implemented by any class that claims to implement the interface. a) attributes b) methods c) variables d) properties

b) methods

Is Python case sensitive when dealing with identifiers? ____________

Yes

Q5. In Python, which of the following can be used to enforce that a class must implement specific methods defined in an interface? a) @abstractmethod decorator c) @enforce decorator b) @interface decorator d) @implementation decorator

a) @abstractmethod decorator

Which of the following is used to define a block of code in Python language? _______ a) Indentation b) Key c) Brackets d) All of the mentioned.

a) Indentation

3. What is the purpose of the super() function in Python? a) It calls the parent class's constructor. b) It is used to create a new object. c) It is used to access class attributes. d) It is a reserved keyword with no function.

a) It calls the parent class's constructor.

Q5. In Turtle Graphics, what does the turtle.forward(100) command do? a) Moves the turtle forward by 100 pixels b) Rotates the turtle by 100 degrees c) Draws a square of side length 100 d) Creates a new turtle object

a) Moves the turtle forward by 100 pixels

What is the purpose of the break statement in Python? a) To terminate the current loop and continue with the next iteration. b) To exit the entire program. c) To skip the current iteration and continue with the next iteration. d) To create a new loop.

a) To terminate the current loop and continue with the next iteration.

02. In Python, which module is commonly used to work with abstract base classes and interfaces? a) abc b) abstract c) interface d) abc interface

a) abc

Which of the following functions is not a built-in function in python? a) factorial() b) print() c) seed() d) sqrt().

a) factorial()

Which of the following is used to create an empty dictionary in Python? a) {} b) [] c) () d) None

a) {}

07. The abc module stands for ________ Base Classes.

abstract

10. To declare an abstract method in an abstract class, you use the ______________ decorator before the method definition.

abstractmethod

Which of the following character is used to give single-line comments in Python? _______ a) // b) # c) ! d) /*

b) #

What is the result of 3 << 2 in binary? _____________ a) 6 b) 12 c) 1 d) 9

b) 12

What is a tuple in Python? a) An ordered collection of elements, mutable and indexed. b) An ordered collection of elements, immutable and indexed. c) An unordered collection of elements, mutable and indexed. d) An unordered collection of elements, immutable and indexed.

b) An ordered collection of elements, immutable and indexed.

In a Python dictionary, keys must be: a) Mutable b) Immutable c) Lists d) Integers

b) Immutable

Q2. What does the pygame,draw, rect function do in Pygame? a) It draws a circle. b) It draws a rectangle. c) It plays a sound. d) It loads an image.

b) It draws a rectangle.

Q1. Which Python library is commonly used for creating 2D graphics and animations? a) NumPv b) Matplotlib c) Pandas d) Requests

b) Matplotlib

Q4. Which of the following libraries is known for its capability to create data visualizations and static 2D graphics in Python? a) Pygame b) Matplotlib c) Turtle Graphics d) OpenCV

b) Matplotlib

5. In Python, a class can inherit from multiple base classes. This feature is known as: a) Multiple Instances b) Multiple Inheritance c) Multiple Polymorphism d) Multiple Abstraction

b) Multiple Inheritance

Q4. Which of the following is true about Python interfaces? a) Python interfaces can be instantiated. b) Python interfaces are similar to abstract classes. c) Puthon interfaces allow for multiple inheritance. d) Python interfaces can have method implementations.

b) Python interfaces are similar to abstract classes.

Which one is not an operator in Python? _______ _a) * b) \\ c) % d) =

b) \\ , this is used for backslashes...

2. Which Python keyword is used to define an abstract method within an abstract class? a) virtual b) abstractmethod c) interface d) method

b) abstractmethod

7. Which of the following is a correct way to create a child class in Python that inherits from a parent class? a) class Child: Parent b) class Child(Parent) c) class Child extends Parent d) class Child(Parent):

b) class Child(Parent)

The database object in an object-oriented model is responsible for: __________ a) Rendering user interfaces b) Handling user input validation c) Interacting with a database, including querying and updating data d) Performing complex mathematical calculations

c) Interacting with a database, including querying and updating data

3. Which of the following is NOT a typical operation associated with a CRUD object? a) Creating new database records b) Retrieving data from a database c) Managing user authentication d) Updating existing data

c) Managing user authentication

Which of the following is NOT a typical operation associated with a CRUD object? _______ a) Creating new database records b) Retrieving data from a database c) Managing user authentication d) Updating existing data

c) Managing user authentication

5. A data-defined object is often designed to encapsulate both data and __________ that operate on that data. a) User interfaces b) Obiects c) Methods d) Files

c) Methods

A data-defined object is often designed to encapsulate both data and __________ that operation that data. a) User interfaces b) Objects c) Methods d) Files

c) Methods

Which access modifier in Python allows an attribute or method to be accessed only within its own class and derived classes? ____________ a) Public b) Private c) Protected d) Internal

c) Protected

9. What is the primary purpose of the pass statement in Python? a) To create a new instance of a class b) To break out of a loop c) To indicate an empty code block or placeholder d) To print output to the console

c) To indicate an empty code block or placeholder

In Python, how can you emulate a "switch-case" statement? a) Using a for loop b) Using a while loop c) Using if-elif-else statements d) Using a tuple

c) Using if-elif-else statements

1. In Python, what keyword is used to define a class as abstract, indicating that it cannot be instantiated directly? a) abstract b) interface c) abc d) class

c) abc

In Python, you can create an instance of a class by using the __________ keyword a) new b) create c) instance d) None of the above

c) instance

An object is an instance of a __________. a) Variable b) Module c) Function d) Class

d) Class

1. In an object-oriented model, a data-defined object typically represents: a) User input validation b) The structure of a user interface c) Mathematical algorithms d) Data entities and their attributes

d) Data entities and their attributes

In an object-oriented model, a data-defined object typically represents: ___________ a) User input validation b) The structure of a user interface c) Mathematical algorithms d) Data entities and their attributes

d) Data entities and their attributes

The self keyword in Python is used to refer to the __________ of an object within a class. a) Class b) Method c) Attribute d) Instance

d) Instance

Q3. Which library is commonly used for creating interactive and dynamic web-based graphics in Python? a) Tkinter b) Matplotlib c) Pygame d) Plotly

d) Plotly

6. To declare a variable in Python as constant, you should: a) Use var keyword b) Use final keyword c) Use const keyword d) Prefix the variable name with an underscore () to indicate it is constant

d) Prefix the variable name with an underscore () to indicate it is constant

4. Which keyword in Python is used to define an interface? a) interface b) abstract c) class d) Python does not have a separate keyword for interfaces

d) Python does not have a separate keyword for interfaces

Which type of Programming does Python support? ____________ a) object-oriented programming b) structured programming c) functional programming d) all of the mentioned

d) all of the mentioned

Which one is the proper for loop syntax in Python? _______ _a) for int in range c) for i in range: b) for int in range(1, n) d) for i in range(1, n):

d) for i in range(1,n):

Q1. In Python, which keyword is used to define an interface? a) interface b) abstract c) class d) interface is not explicitly defined in Python

d) interface is not explicitly defined in Python

Which one is not a convention for variable naming (=identifier) in Python? __________ a) must start with a letter or the underscore character. b) cannot start with a number. c) only contain alpha-numeric characters and underscores (A-z, 0-9, and _ ) d) not case-sensitive

d) not case-sensitive

The primary focus of a CRUD object is to facilitate Create, Read, Update, and Delete operations on __________.

data

Encapsulation is the concept of bundling __________ and methods into a single unit.

data(attributes)

9. In obiect-oriented programming, a data-defined obiect helps in achieving ____________ as it bundles data and methods together.

encapsulation

In object-oriented programming, a data-defined object helps in achieving __________, as it bundles data and methods together.

encapsulation

To emulate a switch-case statement in Python, you can use a series of _____________________statements to perform different actions based on the value of a

if-elif-else

Q8. A class that implements an interface must provide ____________ for all the methods defined in that interface.

implementation

8. The database object is responsible for ______________ data to and from a database, as well as executing complex database ____________.

managing , operations

The database object is responsible for __________ data to and from a database, as well as executing complex database __________.

managing/ operations

09. Python supports ___________ inheritance, where a class can inherit from multiple interfaces.

multiple

To define a tuple containing the values 1, 2, and 3, you would write: mytuple = ____________________

mytuple = _____(1, 2, 3)___

To add a new key-value pair 'age: 25' to an existing dictionary named person, you would use the following code:_______________________________

person['age'] = 25

To access the value associated with a key 'name' in a dictionary named person, you would write:______________________________

person['name']

10. A well-structured CRUD object can significantly enhance the _______________ and maintainability of an application's data operations.

scalability


Ensembles d'études connexes

How Video Games Are Getting Inside Your Head - And Wallet (CommonLit)

View Set

Structure of the Autonomic Nervous System

View Set

Chapter 13 - Enhanced Entity-Relationship Modeling

View Set

Week 1 Perioperative Study Guide

View Set