×

Multiple-Choice Questions

Web Technologies MCQs

Computer Science Subjects MCQs

Databases MCQs

Programming MCQs

Testing Software MCQs

Digital Marketing Subjects MCQs

Cloud Computing Softwares MCQs

AI/ML Subjects MCQs

Engineering Subjects MCQs

Office Related Programs MCQs

Management MCQs

More

Pygame MCQs (Multiple-Choice Questions)

PyGame is a set of Python modules for Game development which can be used to create fully featured games and multimedia programs. PyGame is based on the SDL library. PyGame being Python based is highly portable and runs on almost every platform and operating system.

PyGame MCQs

This section contains PyGame Multiple-Choice Questions with Answers. These PyGame MCQs are written for beginners as well as advanced developers. Practice these MCQs to enhance and test the knowledge of PyGame.

List of PyGame MCQs

The following are the popular MCQs on Pygame:

1. Which function is used to initialize pygame modules?

  1. init()
  2. initialize()
  3. load()
  4. initiate()

Answer: A) init()

Explanation:

To initialize pygame modules, the init() function is used. Consider the below code statements in which we are importing and initialize the pygame module –

import pygame
pygame.init()

Discuss this question

2. Which is the correct code statement to set the pygame display window of specified size x and y?

  1. screenObj = pygame.display.window((x, y))
  2. screenObj = pygame.display.setMode((x, y))
  3. screenObj = pygame.display.set_mode((x, y))
  4. screenObj = pygame.display.set_window((x, y))

Answer: C) screenObj = pygame.display.set_mode((x, y))

Explanation:

The correct code statement to set the pygame display window of specified size x and y is:

screenObj = pygame.display.set_mode((x, y))

Discuss this question

3. Which method is used to set the pygame window's title?

  1. display.set_title()
  2. display.title()
  3. display.setTitle()
  4. display.set_caption()

Answer: D) display.set_caption()

Explanation:

The display.set_caption() method is used to set the caption/title of a pygame window. Consider the below syntax in which we are setting captions to a pygame window.

pygame.display.set_caption("Hi, There…")

Discuss this question

4. Which module contains GUI functionalities to work with the graphical interface in Python?

  1. QtGraphical
  2. PyQtGui
  3. QtCore
  4. QtGui

Answer: D) QtGui

Explanation:

There is a module named QtGui in PyQt which provides the classes and functions for working with the graphical interface in Python.

Discuss this question

5. Which is the correct import statement to import QtGui Module?

  1. from PyQt4 import PyQtGui
  2. from PyQt4 import QtGui
  3. import PyQt4 from QtGui
  4. Both A and B

Answer: B) from PyQt4 import QtGui

Explanation:

The correct import statement to import QtGui Module in Python is:

from PyQt4 import QtGui

Discuss this question

6. Which function is used for defining the size and position of a window in PyQt?

  1. setgeometry()
  2. setGeometry()
  3. getSetGeometry()
  4. set_Geometry()

Answer: B) setGeometry()

Explanation:

PyQt's method "setGeometry()" is used to define the size and position of Windows.

Syntax:

window.setGeometry(x, y, width, height)

Discuss this question

7. Which class is used for rendering and editing HTML in PyQt?

  1. QtWebKit
  2. QtGuiWebKit
  3. QtHtml
  4. Both B and C

Answer: A) QtWebKit

Explanation:

PyQt's class QtWebKit is used for rendering and editing HTML. The QtWebKit is one of the major engines to render web pages and execute JavaScript code.

Discuss this question

8. Which class is used for network programming in PyQt?

  1. QtNet
  2. QtNetworking
  3. QtNetwork
  4. QtNetworkProgramming

Answer: C) QtNetwork

Explanation:

PyQt's class 'QtNetwork' is used for network programming. The 'QtNetwork' class provides the functionalities (classes, method, and set of APIs) for programming applications that use TCP/IP operations such as requests, cookies, and sending data over HTTP.

Discuss this question

9. Which is/are the popular method(s) of QBoxLayout class in PyQt?

  1. addWidget()
  2. addStretch()
  3. addLayout()
  4. All of the above

Answer: D) All of the above

Explanation:

All of the given methods of the QBoxLayout. They are used for the various purposes such as addWidget() method is used to add a widget to the BoxLayout, addStretch() method is used to create an empty stretchable box, and addLayout() method is used to add another nested layout.

Discuss this question

10. Which object acts as a placeholder to display non-editable text or image, or a movie of animated GIF in PyQt?

  1. QLabel
  2. QText
  3. QEditText
  4. QEditLabel

Answer: A) QLabel

Explanation:

A QLabel object acts as a placeholder to display non-editable text or image, or a movie of animated GIF.

Discuss this question

11. Which object(s)/widget(s) is/are used for drawing menus in QMainWindow?

  1. QMenuBar
  2. QMenu
  3. QAction
  4. All of the above

Answer: D) All of the above

Explanation:

The QMenuBar, QMenu, and QAction widgets are used for drawing menus in QMainWindow.

Discuss this question

12. Which function is used to create a popup menu in PyQt?

  1. addPopupMenu()
  2. createPopupMenu()
  3. createPmenu()
  4. QPopupMenu()

Answer: B) createPopupMenu()

Explanation:

In Python, PyQt API has a function named createPopupMenu() which is used for creating a popup menu.

Discuss this question

13. QMessageBox class is used to ____ in PyQt.

  1. Create message box
  2. Create popup box
  3. Send message over TCP/IP
  4. All of the above

Answer: A) Create message box

Explanation:

QMessageBox class is used to create message box in PyQt.

Discuss this question

14. Which is the correct statement to set the position of a widget 'dispWin' to position x and y?

  1. dispWin.move(x, y)
  2. dispWin.windowMove(x, y)
  3. dispWin.setPosition(x, y)
  4. dispWin.position(x, y)

Answer: A) dispWin.move(x, y)

Explanation:

The correct code statement to set the position of a widget dispWin to position x and y is:

dispWin.move(x, y)

Discuss this question

15. The getText() and setText() are the methods of ___ module.

  1. QtEditText
  2. QLineEdit
  3. QtLineEdit
  4. QtText

Answer: B) QLineEdit

Explanation:

The getText() and setText() are the methods of QLineEdit module. Where, the setText() is used for setting the text programmatically, and the getText() is used for getting the text.

Discuss this question

16. Which is the correct code statement to add an option in the menu in PyQt?

  1. menu.addNewMenu('option_name')
  2. menu.Add('option_name')
  3. menu.newMenu('option_name')
  4. menu.addMenu('option_name')

Answer: D) menu.addMenu('option_name')

Explanation:

The correct code statement to add an option in the menu in PyQt is:

menu.addMenu('option_name')

Where, 'menu' is the name of menu bar and 'option_name' is the new option to be added.

Discuss this question

17. Which class is used to align the widgets horizontally in PyQt?

  1. QtBoxLayout
  2. QHBoxLayout
  3. QtHBoxLayout
  4. PyQtHBoxLayout

Answer: B) QHBoxLayout

Explanation:

PyQt provides QHBoxLayout class which is used to arrange widgets in a horizontal box.

Discuss this question

18. Which class is used to align the widgets vertically in PyQt?

  1. QtBoxLayout
  2. QVBoxLayout
  3. QtVBoxLayout
  4. PyQtVBoxLayout

Answer: B) QVBoxLayout

Explanation:

PyQt provides QVBoxLayout class which is used to arrange widgets in a vertical box.

Discuss this question

19. Which is/are the layout manager class(s) in PyQt?

  1. QHBoxLayout
  2. QVBoxLayout
  3. QGridLayout
  4. All of the above

Answer: D) All of the above

Explanation:

There are four general-purpose layout manager classes in PyQt.

  1. QHBoxLayout class is used to arrange widgets in a horizontal box.
  2. QVBoxLayout class is used to arrange widgets in a vertical box.
  3. QGridLayout class is used to arrange widgets in a grid.
  4. QFormLayout class is used to arrange widgets in two columns.

Discuss this question

20. Which is the correct code statement to create canvas in PyQt?

  1. self.image = QImage(self.size(), QImage.Format_RGB32)
  2. self.image = QImage()
  3. self.image = QImage(QImage.Format_RGB32, self.size())
  4. None of the above

Answer: A) self.image = QImage(self.size(), QImage.Format_RGB32)

Explanation:

The correct code statement to create canvas in PyQt is:

self.image = QImage(self.size(), QImage.Format_RGB32)

Discuss this question

21. How to set or change the style to the spin box text in PyQt?

  1. font.setStyle()
  2. font.setStyle(style)
  3. font.style()
  4. font.style(style)

Answer: B) font.setStyle(style)

Explanation:

The font.setStyle() method can be used to set or change the style to the spin box text in PyQt. Consider the below code statement –

font.setStyle(QFont.StyleOblique)

Discuss this question

22. ___ method is used to set the database name in PyQt.

  1. setDatabaseName()
  2. setDbName()
  3. setDBName()
  4. QSetDatabaseName()

Answer: A) setDatabaseName()

Explanation:

The setDatabaseName() method is used to set the database name in PyQt.

Discuss this question

23. Which is/are the correct SQL driver(s) to work with PyQt?

  1. QDB2
  2. QIBASE
  3. QMYSQL
  4. All of the above

Answer: D) All of the above

Explanation:

All of the above are the correct SQL drivers to work with PyQt where QDB2 is used for IBM DB2, QIBASE is used for Borland InterBase Driver, QMYSQL is used for MySQL Driver, and QOCI is used for Oracle Call Interface Driver.

Discuss this question

24. Which driver is used for Microsoft SQL Server in PyQt?

  1. QMSSQL
  2. QMSDB2
  3. QODBC
  4. None of the above

Answer: C) QODBC

Explanation:

The QODBC is the SQL driver in PyQt which is an ODBC driver and also used for Microsoft SQL Server.

Discuss this question

25. Which driver is used for SQLite version 3 or above in PyQt?

  1. QSQLITE3
  2. QSQLITE3x
  3. QSQLITE2
  4. QSQLITE

Answer: D) QSQLITE

Explanation:

The QSQLITE driver is used for SQLite version 3 or above. Where, QSQLITE2 is used for SQLite version 2.

Discuss this question

26. MDI stands for ____ in PyQt.

  1. Multiple Drawing Interface
  2. Multiple DialogBox Interface
  3. Multiple Document Interface
  4. None of the above

Answer: C) Multiple Document Interface

Explanation:

The MDI stands for Multiple Document Interface in PyQt.

Discuss this question

27. Which class provides access to a system-wide clipboard in PyQt?

  1. QtClipboard
  2. QClipboard
  3. PyQtClipboard
  4. QSysClipboard

Answer: B) QClipboard

Explanation:

PyQt has a class QClipboard that provides access to a system-wide clipboard for the various operations related to the copy and paste.

Discuss this question

28. Which QClipboard class's method is used to copy QImage into clipboard in PyQt?

  1. copyImage()
  2. copyQImage()
  3. setQImage()
  4. setImage()

Answer: D) setImage()

Explanation:

The setImage() is a method of QClipboard class that is used to copy a QImage into clipboard in PyQt.

Discuss this question

Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.