Answers |Actual Complete Exam |Already Graded A+
Which of the following Python syntax (code) correctly prints
" Hello World" ✔Correct Answer-print("Hello World")
What will the following print?
result = 1
result = 3 + 2
print(result) ✔Correct Answer-5
What does the following line in a Python code do?
name = "Larry" ✔Correct Answer-Creates a variable called name and assigns it the string
"Larry" (or stores the string "Larry" in the variable name)
Python is a compiled programming language and does not use an interpreter (T/F) ✔Correct
Answer-false
A variable provides a way to label, store and access information in a computer program (T/F)
✔Correct Answer-true
Why would a programmer use
if ... elif ... else? ✔Correct Answer-An if, elif, else statement will execute one block of
statements if its condition is true, or another block if the condition is false. When this statement
executes, the condition is tested. If it is true, the block of indented statements following the if
clause is executed, then control of the program jumps to the statement that follows the if-else
statement. If the condition is false, the block of indented statements following the else clause is
executed, then control of the program jumps to the statement that follows the if-else
statement.
Define programming language ✔Correct Answer-A Programming language is a set of
commands, instructions, and other syntax use to create a software program. it's a formal
language, which comprises a set of instructions that produce various kinds of output.
Programming languages are more often used in computer programming to implement
algorithms.
Name two data types ✔Correct Answer-integers , boolean ,
\n (meaning) ✔Correct Answer-new line
,/ (meaning) ✔Correct Answer-divison
// ✔Correct Answer-a mathematical function (divison) that returns a whole number
% ✔Correct Answer-a mathematical function (divison) that returns the remainder
What does the below Python function do?
round(<put number here>) ✔Correct Answer-round to the nearest whole number
What is syntax? ✔Correct Answer-the grammatical rules and structural patterns for writing
computer code
Write a Python code (program) that:
Prints out the following three lines:
First number: 452
Second number: 35
Third number: 186 ✔Correct Answer-#This program will print the follwing three lines:
print(" first number: ", 452)
print("second number: ", 35)
print (" third number: ", 186)
Write a Python code (program) that:
Calculates the total of the three variables,
var1, var2, var3,
and prints out the variables and the total.
You do not have to actually compute the total or use actual numbers, just write the lines of code
that will total the numbers. Punctuation counts.
You do not need to create a function. ✔Correct Answer-total = var1 + var2 + var3
print(var1, var2, var3, total)
The functions: int(), float(), str() are: ✔Correct Answer-used to convert and/or define data
types in python
, For the following example:
read the first value
while value is not the sentinel:
process the value
read the next value
The example is written in: ✔Correct Answer-pseudocode
Which one of the following is a valid Python
if statement ✔Correct Answer-if a>=22:
The +, -, *, /, and % are arithmetic operators (T/F) ✔Correct Answer-True
What are the two type of loops we have discussed? ✔Correct Answer-while loop and the for
loop
A _____________ error does not prevent the program from running, but causes it to produce
incorrect results. ✔Correct Answer-Logic
Write a conditional statement and explain what it does. ✔Correct Answer-if, else, elif,
it's a condition that if true performs the next step or if false does something else.
A(n) ________________ is a set of well-defined logical steps that must be taken to perform a
task. ✔Correct Answer-algorithm
An informal language that has no syntax rules and is not meant to be compiled or executed is
called ____________ . ✔Correct Answer-pseudocode
This symbol marks the beginning of a comment in Python. ✔Correct Answer-#
Which built-in function can be used to read input that has been typed on the keyboard?
✔Correct Answer-input()