Python Programming Concepts Explained
Python Programming Concepts Explained
What is the name of the process of converting languages where executable code is not generated and the program runs as it is being
converted.
Assembler
Compilation
Translation
Connector
Interpretation
Data Resp.: 08/19/2022 09:59:50
Explanation:
2. 1.
Assembly language
machine language
HTML language
JAVA language
Python language
Data Resp.: 08/19/2022 10:00:46
Explanation:
BASIC PYTHON
III - Has an object-oriented implementation where all attributes are mandatory private.
I and II.
I, III and IV.
II and IV.
II and III.
Data Resp.: 19/08/2022 10:01:23
Explanation:
The Python language is known for having dynamic typing, that is, the assignment of values to a variable occurs during execution.
can be changed dynamically. Its indented syntax promotes code organization and readability. Python adds the
visibility attributes present in object-oriented languages.
4. Data structures are responsible for organizing and storing data efficiently, creating ways for the user to handle them.
Widely used and known structures are stacks, lists, and queues. Regarding Algorithms and Data Structures, given the statements
below, mark the CORRECT alternative:
Python is a compilable language, which, after this process, generates an executable file of the binary type.
Lists in Python are sets of values, which can only be of the same type, accessed by a numeric index that starts at 0.
(zero).
In conditional or loop commands, the separation of code blocks in Python is done using indentation.
Data Resp.: 19/08/2022 10:01:42
Explanation:
The correct answer is: In conditional or looping statements, the separation of code blocks in Python is done using indentation.
Python is an interpreted language that supports object-oriented programming. In Python, it is not necessary to declare a variable before
using it, and the indentation of the code is essential between the blocks for its proper functioning
STRUCTURED PYTHON
import math
print(sqrt(36))
An error will occur because the print() function needs to receive a string as a parameter.
Explanation:
The correct answer is: An error will occur because the correct call should be [Link](36)
16
32
24
20
Data Resp.: 08/19/2022 10:07:37
Explanation:
OBJECT-ORIENTED PYTHON
class End_simple(object):
[Link] = street
[Link] = num
[Link] = neighborhood
def Address(self):
[Link] = com
def Address(self):
...
print([Link]())
print([Link]())
It is known that executing this code produced the following two lines.
Select the option that presents the correct definition for the method Endereco in the class End_com.
Explanation:
The correct answer is: return super(End_com, self).Endereco() + ", " + [Link]
In the Endereco method of the End_com class, a call must be made to the Endereco method of its parent class, the End_simples class, which
return the values for street, number, and neighborhood as a string: return [Link] +,¿+self.νm+,¿+self.νm+? + [Link] (these values
are passed as parameters to the End_simples constructor within the End_com class constructor, as there is a relationship between these two classes.
inheritance relationship). The Endereco method of End_com concatenates the string returned by the Endereco method of End_simples with the value
from the variable [Link] of End_com, this string concatenated is its return value.
8. Within the context of programming languages and object orientation, the concept of polymorphism
describe ways in which abstract and concrete classes can relate. Indicate the alternative that correctly defines polymorphism.
One possible way to implement polymorphism in a programming language is through parametric universal polymorphism.
in which type conversion of the parameters of a function occurs implicitly.
Programming languages that implement the concept of inheritance also need to implement the concept of polymorphism as
construction.
Programming languages that do not have types, such as Python, cannot implement polymorphism.
The implementation of polymorphism in programming languages relies on the concept of late binding, in which the type of a variable is only
It is known at runtime. This means that compiled languages do not have polymorphism in the strict sense.
Polymorphism represents a concept in which the same name (such as a variable, for example) can denote objects of different
classes that are related by a common superclass.
In the context of object-oriented programming, polymorphism is the ability for an object variable to assume, in certain situations,
different forms and behaviors.
Impossible to determine
10
1000000
100000
Data Resp.: 08/19/2022 10:10:47
Explanation:
No
Not Recorded Recorded
Responded
ifn > 1:
The following code will be executed while n is greater than 1.
return foo(n-1)
At this moment we have a product of the value n by the result
of the function applied again, now, on (n - 1). This is where it happens
recursiveness.
return
when n is less than or equal to 1 the function will return n.
print(foo (4))
The result of the function applied to the number 4 will be printed on the screen.
_______________________________
Therefore, it can be observed that the program is executing the
next multiplication: 4 x 3 x 2 x 1 = 24
Python code
Python is a programming language launched in 1991, designed for
programming with several versions already released.
III - The main languages used are: Pascal, Java, and Ruby.
Based on your analysis, mark the ONLY option that presents ONLY the assertions
correct
I, II and IV
I and IV
II, III and IV
III and IV
I
Answered on 08/19/2022 09:32:16
Explanation:
2a Correction:1.0/1.0
Questão
1.
Explanation:
3a
Right:1.0/1.0
Question
Consider the following fragment of source code written in the Python language:
def foo(a):
return a + a + a
b = 1
foo(b)
foo(b)
foo(b)
Após a execução de todos esses códigos, qual é o valor a ser mostrado mediante o
below command?
print(b)
6
0
1
9
3
Answered on 08/19/2022 09:33:30
Explanation:
The function foo aims to return three times the value of a. When we apply the function foo
to the value we should have as a result the value 3. However, it is noticeable that the code does not at all
moment reveals on the user's screen the value of the function foo over variable b. For the value of
return should be 3, the code should be changed to print(foo(b)).
4a Correction:1.0/1.0
Question
Data structures are responsible for organizing and storing data in a way
efficient, creating ways for the user to handle them. Widely used structures
and well-known are stacks, lists, and queues. Regarding Algorithms and Data Structures
Given the statements below, mark the CORRECT option:
Python is a compiled language, which, after this process, generates a
executable file, of the binary type.
Variable declaration is something mandatory in Python.
In conditional or looping commands, the separation of code blocks
In Python, it is done using indentation.
Lists in Python are sets of values, which can only be of the same
type, accessed by a numerical index starting at 0 (zero).
Python is a procedural language that does not include object-oriented programming.
objects.
Answered on 08/19/2022 09:34:53
Explanation:
The correct answer is: In conditional or loop commands, the separation of blocks of
Code in Python is done using indentation.
5a
Correct:1.0/1.0
Question
The snippet of Python code is a recursive function for calculating the factorial of a
any natural number. However, it has a programming error.
On which line is the error and how to fix it so that the function works correctly
your purpose?
the code should be "if (n == 1) and (n == 0):" on line 2.
the code should be "return Factorial(n) * n -1;" on line 5.
the code should be "if (n == 1):" on line 2.
the code should be "return Factorial(n - 1) * n;" on line 5.
the code should be 'return 0' on line 3.
Answered on 08/19/2022 09:35:36
Explanation:
The correct answer is: the code should be "return Fatorial(n - 1) * n;" on line 5.
6a
Correct:1.0/1.0
Question
Observe the print function of the code written in Python below:
Explanation:
7a
Correct:0.0/1.0
Question
(DPE-RJ/2014) Consider the following excerpt from a program written in the language
Python.
class Car(object):
def TalkToMe(self):
I am a car
x = Car()
y = Beetle()
[Link]()
[Link]()
In the first block, the FaleComigo method is defined for the Carro class, which
simplesmente produz a mensagem "Sou um carro" ao ser invocado. Para a classe
Fusca, defined in the second block, the method FaleComUmFusca was defined, which only
produz a mensagem "Sou um Fusca". No terceiro bloco, os objetos x e y tornam-se
instances of the Car and Beetle classes, respectively. In the fourth block, the method
FaleComigo is invoked for each of the two objects, x and y. When executed, this
the program produces two lines on its output screen:
I am a car
I am a car
Polymorphism.
Inheritance.
Interface.
Abstraction.
Associação.
Responded on 08/19/2022 09:37:09
Explanation:
The mechanism that provided the behavior is INHERITANCE. Note that the child class (beetle)
inherits from the mother class (car) its methods and attributes adding a degree of specialization.
8a
Correct:1.0/1.0
Question
Within the context of programming languages
In object-oriented programming, the concept of polymorphism describes ways in which classes
abstract and concrete can relate. Mark the option that defines
correctly polymorphism.
A possible way to implement polymorphism in a language of
programming is through universal parametric polymorphism, in which the
type conversion of the parameters of a function happens implicitly.
Programming languages that do not have a type, such as, for example, Python
they cannot implement polymorphism.
Programming languages that implement the concept of inheritance also
they need to implement the concept of polymorphism by construction.
The implementation of polymorphism in programming languages relies on
late binding concept, where the type of a variable is only known in
execution time. This means that compiled languages do not have
polymorphism in its strict form.
Polymorphism represents a concept in which the same name (such as a
variable, for example, can denote objects of different classes that are
related by a common superclass.
Replied on 08/19/2022 09:37:42
Explanation:
The correct answer is: Polymorphism represents a concept in which the same name (such as
a variable, for example, can denote objects of different classes that are related
for a common superclass.
9a Agreement:1.0/1.0
Question
Consider the following code snippet and answer:
What elements will be present in the variable my_filtered_list after execution?
of this program:
0 and 5
15, 20, 25 e 30
10, 15, 20, 25 e 30
0, 5, 10, 15, 20, 25 e 30
0, 5 and 10
Answered on 08/19/2022 09:39:48
Explanation:
10a
Correct:1.0/1.0
Question
Consider the script and respond.
By replacing the use of Threads with Processes on line 14, what value will be printed?
through line 18
0
1,000,000
Impossible to determine
100000
10
Answered on 08/19/2022 09:40:33
Explanation: