0% found this document useful (0 votes)
16 views36 pages

Understanding Decision Structures in Programming

This document contains a user's answers to various questions about programming and flowcharts. The user receives feedback on whether their answers are correct or if they need to reinforce any topic.

Translated by

ScribdTranslations
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views36 pages

Understanding Decision Structures in Programming

This document contains a user's answers to various questions about programming and flowcharts. The user receives feedback on whether their answers are correct or if they need to reinforce any topic.

Translated by

ScribdTranslations
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

What shape is used to represent a decision point in a diagram?

flow?
User's response:
Rhombo
result

Correct!
Results of the question
It is a multiple decision instruction:
User's response:
Yes- No
Result:

You need to reinforce the topic: Decision Structures


Results of the question
What instruction automatically increases a counter?
User's response:
While
result

You need to reinforce the topic: Repetition structures


Results of the question
When a flowchart is too extensive, what is used to continue?
in another place?
User's response:
Square
Result:

You need to strengthen the topic: Reading flowcharts


Results of the question
What types can decision structures be?
User's response:
Relational, arithmetic, and logical
resultado

You need to reinforce the topic: Decision-making structures


Results of the question

Write what is missing in the following line of code: If _______ Then


User's response:
A condition
Result:

Correct!
Results of the question
What is the instruction that completes the 'Repeat' structure?
User's response:
For
Result:

You need to reinforce the topic: Structures of repetition


Results of the question
A flowchart reads:
User's response:
According to the numbering
Result:

You need to reinforce the topic: Reading flowcharts


Results of the question
What shape is used to represent the start and end of a flowchart?
User's response:
Oval
Result:

Correct!
Results of the question
What shape is used to represent operations in a flowchart?
User's response:
Rectangle
Result:

Correct!

What types can decision structures be?


User's response:
Simple, double and multiple
Result:

Correct!
Results of the question
In a double decision instruction, how many possible options are there if the
Is the logical result false?
User's response:
1
Result:

Correct!
Results of the question
What shape is used to represent a decision point in a diagram?
flow?
User's response:
Rhombo
Result:

Correct!
Results of the question
In addition to FINPARA, what other instruction completes the 'Para' structure?
User's response:
Until
Result:

Correct!

What is the instruction that completes the "Repeat" structure?


User's response:
Until
Result:

Correct!

Level 2
LESSON 1
What logical value results from the following line of code? Result=True and
False and True
User's response:
No value
Result:

You need to reinforce the topic: Basic declarations and instructions of Python
Results of the question
What logical value results from the following line of code? Result=True and
False or True
User's response:
True
Result:

Correct!
Results of the question
Marcela needs to outline different paths in her solution, what characteristic
Should I apply to schedule?
User's response:
Selective
Result:

Correct!
Results of the question
What is the line of code to declare a range of values from 0 to 9?
User's response:
range(0,10)
Result:

Correct!
Results of the question
Mario writes lines of code to maintain an order of execution, what
Which programming feature applies?
User's response:
Sequential
Result:

Correct!
Results of the question
What is the correct code to change a boolean value?
User's response:
x=input('Enter a logical value') print not(x)
Result:

Correct!
Results of the question
In the following image, which is the IDE's toolbar?

User's response:
1
Result

Correct!
Results of the question
What is the correct way to print Hello world in the IDE?
User's response:
Hello world
Result:

You need to reinforce the topic: Integrated development environment for Python
Results of the question
Alejandra informs you that a process is iterative in your solution, what characteristic
Do you need to apply to schedule?
User's response:
Repetitive
Result:

Correct!
Results of the question
In the following image, which is the project bar of the IDE?

User response:
3
Result:

Correct!
LESSON 2
This is the correct way to access an element of a list within a
dictionary
User's response:
value = dictionary['Key'][1]
Resultado

Correct!
Results of the question
Results of the question
This is the correct way to access an element of a dictionary:
User's response:
Value = dictionary['Key1']
Resultado

Correct!
Results of the question
What is the output in the console of the following program?

cadena
for j in range(1,6):
for i in range(0,j):
chain = chain + str(j)
print(string)
User's response:
122333000000000
Result:

Correct!
Results of the question
What is the console output of the following program?

def alpha(number):
resultado = 0
for j in range(1,5):
result += number + 2
beta(result)
return final
def beta(number):
return number/2.0
print(alfa(2))

User's response:
8
Result:

Correct!
Results of the question
It is the correct way to call a function:
User's response:
name(variable)
Result:

Correct!
Results of the question
The instruction to access the element '$' of the following list lst = ["Jorge",
"Mario", ["Octavio", '$'], "Toti", '#'] is:
User's response:
lst[2][1]
Result:

Correct!
Results of the question
A _________ is a block of instructions that can be reused and is used for
organize a program:
User's response:
Function
result

Correct!
Results of the question
What does the following program print to the console if you input the number 3?

Enter a Number:
numeroStr = int(numeroInt)
if(numberInt > 2):
print(numeroStr + "1")
elif(numberInt == 2):
print(numeroStr + "2")
else:
print(numeroStr + "3")

User's response:
31
resultado

Correct!
Results of the question
It is a feature that differentiates tuples from lists:
User's response:
Once defined, their elements can change.
Result:

You need to reinforce the topic: Data Structure


Results of the question
It is a repetition structure that can be instructed on the number of times it is
Can you repeat a block of instructions.
User's response:
For
result

Correct!
Results of the question
It is a repetition structure that keeps repeating a block of code
while a condition is true.
User's response:
While
Resultado

Correct!
Results of the question
In the following code, a secondary decision is:

Enter your age:


Gender (M/F):
if(int(age) >= 18):
if(gender == "M" or gender == "m"):
print("ID: " + "MA" + age + "+")
else:
print("ID: " + "FE" + age + "+")
else:
if(gender == "F" or gender == "f"):
print("ID: " + "Fe" + age + "-")
else:
print("ID: " + "Ma" + age + "-")
User's response:
if(int(age) >= 18):
resultado

Correct!
Results of the question

Is this the correct way to call the following function:

def TriangleArea(Base, Height):


User's response:
AreaTriangulo(12,33)
Result:

Correct!
Results of the question
Decision structures typically evaluate data __________.
User's response:
Booleans
Result:

Correct!
LESSON 3 Results of the question
Which of the following options presents an example of the use of variables of
instance?
User's response:
Worker("Jorge")
Result:

Correct!
Results of the question
Which of the following method statements considers the inclusion of a
tuple as parameter?
User's response:
def speak(self, *phrases):
result

Correct!
Results of the question
What property guarantees that two objects are unique despite sharing the
same characteristics and methods?
User's response:
Identity
Result:

Correct!
Results of the questionResults of the question

Which of the following options presents the correct syntax to do a


call to the method 'accelerate' of the 'car' object?
User's response:
[Link]()
resultado

Correct!
Results of the question
The object-oriented paradigm is a methodology that provides a way
different from organizing and structuring information for complex systems. In
What is this methodology based on?
User's response:
In the interaction of entities
result

Correct!
Which of the following options contains the method declaration of the following
call: [Link](1,2,3,4,5)?
User's response:
def getMaximum(self, *range):
Result:

Correct!
Results of the question
What happens if no value is passed to a method declared with a parameter?
with a predefined value?
User's response:
The method runs with the default value
Result:

Correct!
Results of the question
When defining a class, where should its attributes be declared?
User's response:
Inside the constructor method
result

Correct!

In programming, an object is known as the computer representation of a


physical or imaginary object, whose complexity depends on three dimensions. What
Which of the following options does NOT belong to these dimensions?

User's response:
Concept
Result:

Correct!

Once a class has been declared and defined, objects can be created using
the following syntax:
User's response:
object = Class()
Result:

Correct!
The use of special parameters is an alternative tool in Python for the:
User's response:
Method overloading
result

Correct!

An object has properties that define it and others that extend its
Functions Which of the following is an extensive property?
User's response:
Inheritance
Result:

Correct!

A part of the object is defined by a data set known as


attributes and store the characteristics of the object at a certain moment. A
this property of the object is known as:
User's response:
State
Result:

Correct!

Methods are functions defined by and for the object, which allow its
interaction with the main program and other objects. What property is
defined by these methods?
User's response:
Behavior
Result:

Correct!
Results of the question
In order to create an object, a template or class must be created first.
then define its characteristics. This procedure is known as:
User's response:
Class declaration
Result:

Correct!
Results of the question
The use of special parameters is an alternative tool in Python for the:
User's response:
Method overloading
Result:

Correct!
LESSON 4

Observe the following code and answer, what method is a


implementation of an abstract method?

User's response:
[Link]
Result:
Correct!
Observe the following code and answer, what instruction generates an error
on screen?

User's response:
g.getSalary2()
Result:
Correct!

From the following implementation of inheritance, which class is inheriting?


their methods and attributes?
class Tiger(Feline):
User's answer:
Feline
resultado
Correct!
Observe the following code and respond. What attribute is being
hiding?

User's response:
salary
result
Correct!

Following the logic of object orientation and based on the following


example, in what order should inheritance be implemented?
User's response:
Person <- Athlete <- Swimmer
Result:
Correct!
Which of the following options presents the correct way to hide
the methods of the objects?
User's response:
__method(self):
Result:
Correct!

Which of the following options presents the correct way to hide


the attributes of objects?
User's answer:
self.__attribute
Result:
Correct!

Study the following code. If an instance of the class 'Animal' is created


And the method is called 'move'. What will be the result in the console?

User's response:
An error in the console indicating that the method does not exist within the object
Result:
You need to reinforce the topic: Inheritance and method overriding

The encapsulation of the methods and attributes of an object is carried out


end by a reserved syntax called:
User's response:
Access modifiers
Result:
Correct!
Information encapsulation is a mechanism of objects.
that allows:
User's response:
Facilitate interaction with other objects within the program
Result:
You need to reinforce the topic: Encapsulation and hiding in objects

Python does not natively support abstract classes, what


instruction allows loading the necessary structure for your
implementation?
User's response:
from ABCMeta import abc, abstractmethod
result
You need to reinforce the topic: Abstract classes

LESSON 5

Complete the following code with the appropriate method, if required.


cambiar la palabra "convirtiendose" por "convirtiendose" en la cadena.

We are the miracle of force and matter transforming themselves into it.
the same in imagination and will
print(cadena3.________("transforming", "becoming"))
User's response:
replace
Result:
Correct!

The following line of code refers to:


C=open('[Link]','w')
User's response:
File writing
Result:
Correct!
To write data to a file, the mode used is:
User's response:
w
Resultado
Correct!

What is the configuration file library in Python?


User's response:
ConfigParser
Result:
Correct!

To read data from a file, the mode used is:


User's response:
r
Resultado
Correct!

What is the Python library for FTP configuration files?


User's response:
netrc
Result:
Correct!

Complete the following code with the appropriate method, if required.


separate the string with an underscore.

print("_".join("LAPIZ"))
User's response:
split
result
You need to reinforce the topic: Chain methods
Complete the following code with the appropriate method, if required.
change the entire string to uppercase.

Shortcuts bring long delays, but the inns


stretch even more
print(cadena2.__________())
User's response:
upper
Result:
Correct!

Complete the following code with the appropriate method, if required.


count the number of times the word 'no' is repeated in the string.

The universe not only has a history, but any history.


possible
print (string1._________("no"))
User's response:
count
Resultado
Correct!

Complete the following code with the appropriate method, it is required


remove the number 31 from the list.

lista3=[23, 84, (23, 53, 98), 31]


list3._________(31)
print(lista3)
User's response:
append
Result:
You need to reinforce the topic: List methods
LESSON 7
From the following code and the result in the console, why does that appear?
error?
Code
import sqlite3
def insert():
db1=[Link]('[Link]')
You are in insert
name1=input("Enter the student's name ")
Enter the group you belong to
query=[Link]()
insert into table(name, group) values
('
print(strConsulta)
[Link](strConsulta)
[Link]()
[Link]()
[Link]()
insert()

Console output
[Link]: no such table: table
User's response:
The table has not been created.
Result:
Correct!
Results of the question
What is the method to execute an SQL statement?
User's response:
execute
result
Correct!

What is the method to close the database connection?


User's response:
close
Result:
Correct!

In the following code, what is the 'return' statement used for?

def consult():
db2 = [Link]("[Link]")
You are in the consult function
db2.row_factory = [Link]
query = [Link]()
[Link]("select * from table")
rows = [Link]()
list = []
for row in rows:
s = {}
row['name']
fila['grupo']
[Link](s)
[Link]()
[Link]()
return(list)
consult()
User's response:
To return the created list
Result:
Correct!

To work with databases in Python, a library that you can


importing is:
User's response:
sqlite3
Resultado
Correct!
Results of the question
What is the method to save changes to the database?
User's response:
commit
Result:
Correct!

In the following code, how many fields does the table have?

import sqlite3
connection=[Link]('[Link]')
query = [Link]()
CREATE TABLE table
(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
name VARCHAR(30) NOT NULL,
group INTEGER(9) NOT NULL);
if([Link](table)):
The table was created
else:
The table was not created
close the query
[Link]()
[Link]()
User's response:
2
result
You need to reinforce the topic: Creation of a table
Results of the question
They ask you to verify that a table was created in the database.
How do you do it?
User's response:
You check the writing of the database file
Resultado
Correct!
Results of the question
From the following code, why is the message "You are in" printed?
the insert function?

import sqlite3
db1=[Link]('[Link]')
You are in the insert function
Enter the student's name
group1=input("Enter the group you belong to ")
query=[Link]()
insert into table(name, group) values
('"+name1+"','"+group1+"')
print(strConsulta)
[Link](strConsulta)
[Link]()
[Link]()
[Link]()
User's response:
To verify that the connection was created
Result:
Correct!
Results of the question
In the following code, what is the method that closes the connection?

def consult():
db2 = [Link]("[Link]")
You are in the consult function
db2.row_factory = [Link]
query = [Link]()
[Link]("select * from table")
rows = [Link]()
list = []
for row in rows:
s = {}
row['name']
fila['grupo']
[Link](s)
[Link]()
[Link]()
return(list)
consult()
User's response:
[Link]()
Result:
Correct!
Results of the question

What is the method to save the query result?


User's response:
fetchall
Result:
Correct!
Results of the question
To be able to query records, you must first create:
User's response:
Tables
Result:
Correct!

LEVEL 3
LESSON 1

According to the following result, what is the missing logical operator?, if


the condition is that a>b>c.

a=b=c=0
for i in range(0,7):
if a > b _____ b > c:
c += 1
b+=1
elif a != 0:
b+=1
a += 1
print "a = " + str(a), " b = " + str(b), " c = " + str(c)
User's response:
and
Result:

Correct!
Results of the question
If no error is found, what label does the language choose to execute
your lines of code?
User's response:
else
Result:

Correct!

What is the error in the following program? Use the flowchart.

NUM=int(input("Enter a number from 1 to 4, according to your level of


English with 4 being the highest value.
if NUM==1:
You need to study more
elif NUM==2:
Keep studying
elif NUM==3:
Don't stop studying, you are on the right path
elif NUM==4:
Excellent!, review constantly

User's response:
The program is not complete
Result:

Correct!
In debugging verification, intentional pauses are used,
known as:
User's reply:
Breakpoints
result

Correct!
Results of the question
According to the following code, what should be put as a method in the
last line of code if Juan wants to send a message?

class Person:
def __init__(self, age, name):
age
[Link] = name
Created
def speak(self, words):
print [Link], ': ', words

Person(30, "Juan")
Hello friend
User's response:
to talk
Result:

Correct!
results of the questionResults of the question
What kind of exception should you add to the following code?
try:
i=0
a=32405
while i<=100:
c=a/b
i+=1
b=b-1
print str(i) + ". The division is " + str(c)
except
There is an error
User's response:
except NameError
Result:

Correct!
Lizeth identifies that many errors come from incorrect values.
When an input is requested from the program, what should be implemented?
User's response:
Exceptions
result

Correct!
Results of the question
According to the following code and its result, what is the solution for
correct the error?
class Person:
def __init__(self, age, name):
age
[Link] = name
A new instance has been created for
def speak(self, words):
print [Link], ': ', words

Person
[Link]("Hello friend")
User's response:
Missing parameters to create the constructor
Result:

Correct!

What type of exception should you add to the following code?


class Person:
def __init__(self, age, name):
[Link] = age
[Link] = name
A has been created for
def speak(self, words):
print [Link], ': ', words
try:
juan = Persona(30, "Juan")
[Link]()

except:
There is an error
User's response:
except TypeError
Result:

Correct!

What type of exception should you add to the following code?


try:
lista1=["Ramiro","Jose","Eduardo", "Laura", "Martin"]
lista2=["Juan"]

for i in range(0,10):
[Link](lista1[i])
print list2

except:
There is an error
User's response:
except LookupError
Result:

Correct!

Mitzy realizes that she cannot run her program in the IDE, what about
What type of error is it?
User's response:
Syntax
result

Correct!

Make a table to manually verify the following code.


x=0
y=1
for i in range(0,10):
x,y=y,x+y
print (y)

In what iteration is y=13? Consider that the first iteration starts with
i=0.
User's response:
5
result

Correct!
Create a table to manually verify the following code.

i=0
x = 55
while i <= 25:
x=x-3
if x == 37:
X is worth less than 40
break
i += 1
print(x)

In which iteration will it display the message "X is less than 40"?
Consider that the first iteration starts with i=0.
User's response:
5
Resultado

Correct!
Results of the question
Results of the question
What type of error is it according to the code and its result?
class Person:

def __init__(self, age, name):


age
name
print "Se ha creado a ", [Link], " de ", [Link]
def speak(self, *words):
for phrase in words:
print [Link], ': ', phrase
juan = Person()
Hello, I am speaking
luis = Person()
Hello Juan, I am Luis

Result in the console


TypeError: __init__() takes exactly 3 arguments (1 given)
User's response:
Execution
Correct!
According to the following code, identify the type of error.
XI=[6, 3, 9,500]
for i in range(0,10):
XI[i]="num" + str(i) + " = " +str(XI[i])
print XI
User's response:
Execution
Result:

Correct!
Results of the question
According to the following result, where is the logical error if the
The condition is that a > b > c?

a=b=c=0
for i in range(0,7):
if a>b or b>c:
c+=1
b += 1
elif a != 0:
b+=1
a += 1
print "a = " + str(a), " b = " + str(b), " c = " + str(c)
User's response:
In the condition of the if
Result:

Correct!

LESSON 2

They are used to describe the functioning of a process:


User's response:
Comments
resultado
Correct!
Results of the question
It is an example of a docstring:
User's response:
Comment
Resultado
Correct!
Results of the question
Testing and verifying the operation of a program is part of the
process of:
User's response:
Refactoring
Result:
Correct!
Results of the question
Its objectives of refactoring, except:
User's response:
Make the program clearer
Result:
You need to reinforce the topic: Code Refactoring
Results of the question
It serves to describe and explain the parts of a program:
User's response:
Documentation
Result:
Correct!
Results of the question
It is an example of a comment:
User's response:
#Comment
Result:
Correct!
Results of the question
At the time of documenting a class, method, or function, you must add
the following data:
User's response:
Name
Result:
Correct!
Results of the question
Eliminating redundancies and facilitating code addition are part of the
documentation?
User's response:
Incorrect
resultado
Correct!
Results of the question
If you refactored code and it works differently and you couldn't
to undo the changes, you must:
User's response:
Use the original program
Result:
Correct!
Results of the question
What type of documentation should you use to add a description to
a class immediately after its definition?
User's response:
Doctrines
result
Correct!
LEVEL 4
LESSON 1

These are the elements you should consider in your quote:


User's response:
Work samples
VAT
Transport
Result:
Correct!
Results of the question
If a user has questions during the explanation, what you should do is
to do is:
User response:
Clarify and anticipate others that may arise from the interaction.
result
Correct!
Results of the question
If you were to dedicate yourself to programming information pages and platforms,
you would be developing in the area:
User's response:
Web
resultado
Correct!
Results of the question
If the project is already advanced, a client requests changes due to new
requirements, what should you do?
User's response:
You offer two free changes and the others at a percentage cost.
of the project
Result:
Correct!
Results of the question
What you can do to endorse the packages and software you handle.

User's response:
take courses and certifications
Result:
Correct!
Results of the question
The ___________ is the stage of the general development process of
software where the project requirements are raised.
User's response:
planning
Result:
Correct!
Results of the question
In order to reach a solution to a problem, you must:
User's response:
implement all possible solutions
Result:
You need to strengthen the topic: Professionalization
Results of the question
The database model is developed at this stage:
User's response:
planning
result
Correct!
Results of the question
Some ways to receive feedback are:
User's response:
Thank the changes proposed by others
Listen attentively to other people's points of view
Result:
Correct!
Results of the question
When quoting a project, what factor most significantly determines the price?
of this?:
User's response:
Complexity
result
Correct!

Results of l
Results of the question

Results of the question

You might also like