Python Programming Concepts and Structures
Python Programming Concepts and Structures
1) Flow control in a program refers to the logical order of execution of the commands that the
comprise, as well as the deviations in that order necessary due to certain conditions that may occur
(BANIN, p. 49, 2018)
Alternatives:
a) A simple conditional structure, where a discount will be applied depending on the value.
b) A simple conditional structure, where an increase will be applied depending on the value.
c) A chained conditional structure, where a discount will be applied depending on the value.
d) A loop structure, which will apply an increment depending on the value.
e) A chained conditional structure, which will apply an increase depending on the value.
2) The linear search is the simplest search algorithm, it traverses the entire collection comparing the
a key with the value of the element in each position. The _____________ search is efficient for a structure.
of ordered data.
Select the option that correctly completes the gap:
Alternatives:
The mission of the Python Software Foundation is to promote, protect, and advance the programming language.
Python, in addition to supporting and facilitating the growth of a diverse and international community of
Python programmers.
Alternatives:
A store needs to implement a solution to calculate the discount on the customer's purchase. If the customer
make a purchase up to R$ 100, the discount will be 3%. If the purchase is up to R$ 500, the discount will be
10%, if it is up to a thousand, the discount will be 20%.
["Alternatives:"]
7-3-2-5-1-6-4-8
b) 2 - 3 - 1 - 5 - 4 - 6 - 7 - 8
c) 2 - 3 - 1 - 5 - 4 - 6 - 8 - 7
d) 7 - 2 - 3 - 1 - 5 - 4 - 6 - 8
e) 7 - 1 - 5 - 6 - 4 - 3 - 2 - 8
5) In the last 3 years, the PSF has been working on donation-funded projects to improve the
internal systems and platforms. This work was carried out with the Packaging Working Group and focused on
PyPI and pip ecosystem. In this way, it was possible to show that the application of targeted funding to
open source projects have the ability to drastically increase the speed of development and
to advance our community in a much more sustainable way than relying solely on efforts
volunteers (Holscher, 2020).
def my_function(value):
for i, c in enumerate(valor):
if [Link]() == 'a' or [Link]() == 'e':
print(c, i)
else:
continue
Considering the code presented, mark the option that correctly describes what it represents.
Alternatives:
a) A function that counts how many vowels 'a' and 'e' exist in a string.
b) A function that checks if a certain value is an integer or a character.
c) A function that locates and displays the position of each vowel 'a' or 'e', regardless of whether it is uppercase or lowercase.
lowercase.
d) A function that only locates the lowercase vowels 'a' or 'e'.
e) A function that locates and displays the position of lowercase vowels 'a' or 'e' and counts them.
amount found.
Alternatives:
A module can contain both executable instructions and definitions of functions and classes.
III- It is not possible to create new modules, only to use those that the language offers.
Select the correct alternative:
Alternatives:
The relational approach represents a way of describing the database through concepts.
simple mathematics: Set Theory. Aimed mainly at improving the understanding of data by
users, this approach makes users see the database as a set of tables
two-dimensional, originated from rows and columns. The main concept comes from Set Theory linked
the conception that it is not relevant for the user to know where the data is or how the data is
(transparency) (MACHADO, p. 38, 2020).
Based on the SQLite relational database mechanism in Python, evaluate the following assertions.
I. CRUD is an acronym for the four DDL operations we can perform on a table in the database.
data
II. The first letter of CRUD - "C" stands for CREATE and pertains to the operation of creating new databases.
relational data.
III. The second letter of CRUD - 'R' stands for READ and is related to the SELECT statement of SQL.
Select the correct alternative.
Alternatives:
9) The objective of a data model is to ensure that all existing data objects in
determined context and required by the application and the database are fully represented
and accurately. The data model must also be detailed enough to be used by
database implementer (DBA) of the database as a kind of photocopy to build the database
Physical. All the information in the logical data model will be used to define the tables of a
relational database, primary keys and foreign keys, stored procedures
procedures) and triggers (MACHADO, p. 17, 2020).
Considering the SQLite relational database mechanism in Python, evaluate the following statements.
(V) True or (F) False.
I. The [Link]() command is used to capture the rows in a table, resulting from a
SQL SELECT statement.
II. ( The command result = [Link]() stores in the variable 'result' a list of tuples, in which
each tuple is a row in the database table.
III. ( The for loop can be used to iterate over each captured record with the
[Link]().
Select the correct alternative.
Alternatives:
V-V-V
b) V - F - F
c) V - V - F
d) F - V - V
e) F - F - V
10) All attributes (columns) of a relation must be atomic, that is, indivisible in terms of
values and components. This means that there are no subgroup type columns; all are items.
elementary, not subdivided under any circumstances and where the existence of multiple is also not permitted.
occurrence of values (multivaluation) in none of its attributes (columns). It is important to understand
that each line of a table represents an object, a subject that is described by the values of each one
of these columns. Domain represents the set of admissible atomic values of a component (column)
from a relationship (table) (MACHADO, p. 42, 2020)
Para fazer uma operação READ em um banco é necessário seguir os seguintes passos:
1. import sqlite3
2. cursor = [Link]()
3. [Link](query)
4. print(line)
5. resultado = [Link]()
6. conn = [Link]('my_database.db')
7. for line in result:
8. query = "SELECT * FROM fornecedor"
Select the option that presents the correct sequence.
Alternatives:
a) 1 - 3 - 5 - 4 - 7 - 2 - 8 - 6
b) 1 - 6 - 2 - 8 - 3 - 5 - 7 - 4
c) 8 - 7 - 6 - 3 - 1 - 5 - 2 - 4
d) 1 - 5 - 2 - 3 - 7 - 8 - 6 - 4
e) 1 - 8 - 7 - 3 - 2 - 5 - 4 - 6
Unit 1
1) Variables are spaces allocated in memory _______, to temporarily store values. In Python,
these spaces do not need to be _________, that is, the variable can be allocated without specifying the ________
that she will wait. The Python interpreter is able to determine the data type of the variable based on its
_____, that is, the variables are typed _________ in this language.
Choose the option that correctly fills in the blanks.
Alternatives:
2) To know the type of data that a variable holds, the Python interpreter relies on the function type().
Alternatives:
a)
int
str
float
bool
b)
integer
str
decimal
bool
c)
float
str
decimal
bool
d)
integer
string
float
string
e)
float
string
float
string
3) The Python programming language supports the four basic mathematical operations, in addition to others. The
the following code is a snippet of a program in Python.
1. x = 4
2. y = 5
3. print(x / y)
4. print(x // y)
Considering the code snippet in Python, choose the option that represents what will be printed by
lines 3 and 4.
Alternatives:
The condition for a student to pass is to have a final average of 7 points or higher. This condition can be
implemented in the Python language, through a conditional structure.
Considering the Python language, choose the option that correctly implements the condition for the student.
to be approved.
Alternatives:
a)
if media_final > 7:
approved
b)
c)
if media_final >= 7:
approved
d)
if media_final < 7:
approved
e)
Python was released in the early _____ by _______ van Rossum at the Stichting Mathematisch
Centrum (CWI), in the Netherlands, as the successor of a language called _______. ________ is the main
author of Python, although it includes many contributions from other researchers.
Choose the option that correctly completes the gaps.
Alternatives:
6) Python is a programming language ______ clear and powerful that uses a ________ elegant,
making it easier to read the programs you write. Comes with a great _______ standard that supports
many common programming tasks, such as connecting to web servers, searching for text with
regular expressions, read and modify files.
Choose the option that correctly completes the blanks.
Alternatives:
One of the great characteristics of language is its _________. One of Guido's main ideas is
that the code is _______ much more often than it is ________. Such an aspect is so relevant that,
A piece of code that follows the rules of the Python language is called a "___________." These rules are defined
by _______ (Python Enhancement Proposal) and relate to formatting, indentation, parameters in
functions, and everything else that may be related to code syntax.
Choose the option that correctly fills in the blanks.
Alternatives:
There are several elements that are part of programming techniques, regardless of the language.
programming. Figure 1 presents an element of programming.
Alternatives:
a) Loop structure.
b) Decision structures.
c) Function.
d) Recursion.
e) Modules.
Unit 2
1) Objects of type ________ are data structures capable of storing _______ value. These
data structures represent sequences ______ indexed by numbers __________.
Choose the option that correctly completes the blanks.
Alternatives:
2) The first element of a sequence occupies ____, the second 1, the last element occupies the position
______, where n is the capacity of ________ of the sequence. Some operations that can be performed with
sequences in Python are: in, ____, sum (+), among others.
Choose the option that correctly completes the blanks.
Alternatives:
3) A text is an object of the class _____, which is a type of ________. Objects of the str class have
certain operations, such as, in, _____, among others. This type of object is _________, that is, it does not
it is possible to assign a new value to a _________.
Choose the option that correctly fills in the blanks.
Alternatives:
4) The notation _______, represents a _________ complexity, that is, the execution time will increase.
linearly with the size of the input. Other complexities that are commonly encountered are:
O(log N), O(N2), O(N3). It is worth noting that in terms of efficiency we will have: O(1) < O(log N) < _____ <
O(N2) < O(N3) < O(2N) that is, an algorithm with O(N) complexity is more efficient than _______.
Choose the option that correctly fills in the blanks.
Alternatives:
5) All _______ in a Python program are represented by __________ or by the relationship between
objects. Everything in Python is an ________, that is, it is a structure that has certain characteristics and
________.
Choose the option that correctly fills in the blanks.
Alternatives:
6) A _______ can be more _______ than a primitive type, for example, the type ________ int, in the
The C language occupies a maximum of 4 bytes (32 bits) and can store values between -2,147,483,648 and
2,147,483,647. On the other hand, the int type object in the Python language does not have a defined limit; such an object remains
limited only to the available memory ______ in the environment.
Choose the option that correctly fills in the blanks.
Alternatives:
The type of the ______ determines the values it can store and the ______ that can be made with it.
In such structure, for example, the class _____, in languages like C, a string is an array of the primitive type.
_______, already in Python, this object, besides having unlimited size, has several _______ for manipulation of
texts, such as split(), replace(), among others.
Choose the option that correctly fills in the blanks.
Alternatives:
Computational _______ are developed and used to solve various problems, in this
universe, as the name suggests, _____ algorithms solve problems related to _____ values in
a _________.
Choose the option that correctly fills in the blanks.
Alternatives:
Unit 3
1) Objects are the components of an OO program. A program that uses OO technology is basically
a collection of _______. A ______ is a model for an object. We can consider a ________,
as a way to organize the data (of an object) and its ____________.
Choose the option that correctly fills in the blanks.
Alternatives:
2) Let's think about the construction of a house, before the "house object" exists, an architect made the blueprint,
determining everything that should be part of that object. Therefore, the _____ is the model and the ______ is a
______. Instance refers to the physical existence, _________, of the object.
Choose the option that correctly completes the blanks.
Alternatives:
3) The data stored in an object represents the state of the object. In programming terminology
Oh, this data is called ________ and it contains the ___________ that differentiate the various
objects. The ________ of an object represents what the object can do. In procedural languages, the
behavior is defined by procedures, functions, and subroutines. In OO programming terminology,
these behaviors are contained in the ________.
Choose the option that correctly fills in the blanks.
Alternatives:
4) The development of software involves good programming practices. In Python, all imports
they must remain in the _______ of the file. According to the documentation, it is good practice to declare first the
libraries ______, followed by the libraries _______ and finally, _______ created for the application. Each
block must be separated by a blank line.
Choose the option that correctly fills in the blanks.
Alternatives:
5) As __________ change very quickly in the software industry, while the concepts __________.
Therefore, it is necessary to understand the concepts in order to _________ in the technology adopted by the company (and this
technology can change ___________) (Weisfeld, 2013).
Alternatives:
6) Software development ________ has existed since the early 1960s, but it was only in
the mid-____ decade that the object-oriented paradigm began to _______ (Weisfeld, 2013).
Choose the option that correctly fills in the blanks.
Alternatives:
7) Object-oriented software development (OO) has existed since the early 1960s, but it was
Only in the mid-1990s did the object-oriented paradigm begin to gain momentum. A
a language is considered object-oriented if it applies the concept of __________ and supports the
implementation of _________, of __________ and of polymorphism.
Choose the option that correctly fills in the blanks.
Alternatives:
["abstraction","function","inheritance"]
["function","encapsulation","inheritance"]
["abstraction","encapsulation","inheritance"]
["encapsulation","inheritance","method"]
e) attributes; method; class
A solution may start with a few lines of code, but soon become hundreds.
thousands and even millions of lines. In this scenario, working with a single flow of code becomes unfeasible,
giving rise to implementation techniques to organize the solution. One option to organize the code is
implement in ________, thus each block is responsible for a certain functionality. Another
the way is to use __________ and create classes that encapsulate the characteristics and behaviors of a
determined ________.
Choose the option that correctly fills in the blanks.
Alternatives:
1) To use the pandas library, you need to install it using the command: pip install ________.
As a high-level tool, pandas has two data structures that are the main ones for the
data analysis/manipulation: a Series and the DataFrame. A Series is like ______________, capable of
store different types of data. A DataFrame is ___________, or as the documentation presents,
a container for Series.
Choose the option that correctly fills in the gaps.
Alternatives:
To construct an object of the DataFrame type, we need to use the _________ method from the pandas package.
Among all the expected parameters, only one is mandatory to create a DataFrame with data, the
parameter ________. This parameter can receive an iterable object, such as a list, tuple, ________ or
a DataFrame.
Choose the option that correctly fills in the blanks.
Alternatives:
Alternatives:
Alternatives:
Databases in general do not contain all possible information about something stored there. A
data is an organized form of information, but it occurs as long as specific fields are
filled in so that their recovery occurs automatically (IIMA, 2015).
Regarding data storage in files, choose the correct option.
Alternatives:
6) A library created to work with data needs __________ that supports storage and
manipulation. The Python language has some structures that are already part of its standard interpreter,
such as the _________, capable of storing a sequence of values and increasing or decreasing
your capacity according to the need, or else the __________, which are structures that store the
data in key-value format.
Choice a option what complete correctly as gaps.
Alternatives:
Alternatives: