If w is a correctly created main application window, which method would you use to foe both of the main window's dimensions?
Answer : C
1. w.resizable()
Theresizable()method takes two Boolean arguments,widthandheight, that specify whether the main window can be resized in the corresponding directions. PassingFalseto both arguments makes the main window non-resizable, whereas passingTrueto both arguments (or omitting them) makes the window resizable.
Here is an example that sets the dimensions of the main window to 500x400 pixels and makes it non-resizable:
import tkinter as tk
root = tk.Tk()
root.geometry('500x400')
root.resizable(False, False)
root.mainloop()
Tkinter documentation:https://docs.python.org/3/library/tk.html
Tkinter tutorial:https://www.python-course.eu/python_tkinter.php
1: https://stackoverflow.com/questions/36575890/how-to-set-a-tkinter-window-to-a-constant-size
Other methods that can be used to control the window size are:
w.pack_propagate () and w.grid_propagate (): These methods allow you to enable or disable the propagation of the size of the widgets inside the window to the window itself. By default, these methods are set to True, which means that the window will adjust its size according to the widgets it contains. You can set these methods to False or 0 to prevent this behavior, such as w.pack_propagate (0) or w.grid_propagate (0).
w.place (): This method allows you to place the window at a specific position and size relative to its parent window or screen. You can use keyword arguments such as x, y, width, height, relx, rely, relwidth, and relheight to specify the coordinates and dimensions of the window in absolute or relative terms, such as w.place (x=0, y=0, relwidth=1, relheight=1).
Select the true statement about the___name___attribute.
Answer : D
The true statement about the__name__attribute isD.nameis a special attribute, which is inherent for classes, and it contains the name of a class. The__name__attribute is a special attribute of classes that contains the name of the class as a string.
The__name__attribute is a special attribute in Python that is available for all classes, and it contains the name of the class as a string. The__name__attribute can be accessed from both the class and its instances using the dot notation.
Which function or operator should you use to obtain the answer True or False to the question: "Do two variables refer to the same object?"
Answer : D
To test whether two variables refer to the same object in memory, you should use theisoperator. Theisoperator returnsTrueif the two variables point to the same object in memory, andFalseotherwise.
For example:
a = [1, 2, 3]
b = a
c = [1, 2, 3]
print(a is b) # True
print(a is c) # False
In this example,aandbrefer to the same list object in memory, soa is breturnsTrue. On the other hand,aandcrefer to two separate list objects with the same values, soa is creturnsFalse.
Theisoperator is used to test whether two variables refer to the same object in memory. If two variablesxandyrefer to the same object, the expressionx is ywill evaluate toTrue. Otherwise, it will evaluate toFalse.
In the JSON processing context, the term serialization:
Answer : A
In the JSON processing context, the term serialization: A. names a process in which Python data is turned into a JSON string.
Serialization refers to the process of converting a data object, such as a Python object, into a format that can be easily transferred over a network or stored in a file. In the case of JSON, serialization refers to converting Python data into a string representation using the JSON format. This string can be sent over a network or stored as a file, and later deserialized back into the original Python data object.
Select the true statements about sockets. (Select two answers)
Answer : A, D
1. A socket is a connection point that enables a two-way communication between programs running in a network.
2. A socket is always the secure means by which computers on a network can safely communicate, without the risk of exposure to an attack.
3. A socket is a connection point that enables a one-way communication only between remote processes.
4. A socket can be used to establish a communication endpoint for processes running on the same or different machines.
The following snippet represents one of the OOP pillars Which one is that?
Answer : C
The given code snippet demonstrates the concept of encapsulation in object-oriented programming. Encapsulation refers to the practice of keeping the internal state and behavior of an object hidden from the outside world and providing a public interface for interacting with the object. In the given code snippet, the__init__andget_balancemethods provide a public interface for interacting with instances of theBankAccountclass, while the__balanceattribute is kept hidden from the outside world by using a double underscore prefix.
Look at the following examples of comments and docstrings in Python Select the ones that are useful and compliant with PEP 8 recommendations (Select the two best answers.)
A)
B)
C)
D)
Answer : B, D
According to PEP 8 recommendations, the two best options areOption BandOption D.