Docsity

ENGR 102 Exam 1: Python Programming Fundamentals, Quizzes of Advanced Education

Toggle sidebar
bg1
ENGR 102 Exam 1 (Collection of quizzes an answers) with
Complete Solutions |100% Pass
Write the output of the following code:
x = 3
y = 4
z = x * y
z += 2
print(z) - ✔✔14
What is the output of the following code:
print(((2 ** 3) + 3 * 5) * (sqrt(49) // 4) + (23 % 7)) - ✔✔(8 + 15) * (7 // 4) + 2 23 * 1 + 2 25.0=
26.286
Starting with the following code, write one line of code that prints the value of 2-√2 (square
root of 2) to the screen.
from math import *
# your code goes here - ✔✔from math import *
print ( sqrt(2) )
Which of the following are valid variable names in python? Mark all that apply.
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Partial preview of the text

Download ENGR 102 Exam 1: Python Programming Fundamentals and more Quizzes Advanced Education in PDF only on Docsity!

ENGR 102 Exam 1 (Collection of quizzes an answers) with

Complete Solutions |100% Pass

Write the output of the following code: x = 3 y = 4 z = x * y z += 2 print(z) - ✔✔ 14 What is the output of the following code: print(((2 ** 3) + 3 * 5) * (sqrt(49) // 4) + (23 % 7)) - ✔✔(8 + 15) * (7 // 4) + 2 23 * 1 + 2 25.0=

Starting with the following code, write one line of code that prints the value of 2-√2 (square root of 2) to the screen. from math import *

your code goes here - ✔✔from math import *

print ( sqrt(2) ) Which of the following are valid variable names in python? Mark all that apply.

Length 3rdplace kinetic-energy Correct! _time - ✔✔Length _time Arrange the following mathematical operators in the correct order of operations according to python. 1 is the first and 4 is the last. - ✔✔( ) ** %

Floating-point numbers have a decimal point TRUE or FALSE - ✔✔True Strings can be defined with single quotes ('') or double quotes ("") T or F - ✔✔True Which of the following expressions produce an integer for variable x? Choose all that apply.

Which of the following is a valid operation (will NOT result in an error)? msg = float('whoop') x = float('9.1.21') y = '10' / '5' mynum = int(float('1.5')) - ✔✔mynum = int(float('1.5')) Write the output of the following code: print("ENGR", 100 + 2, sep='_', end='!')print('Whoop') - ✔✔ENGR_102!Whoop Which of the following examples use valid relational operators? Mark all that apply. x =< y my_shoe_size != 10 my_cars < 3 my_name == 'me' - ✔✔my_shoe_size != 10 my_cars < 3 my_name == 'me'

What is the output of the following code? a = 20 b = 5 c = 10 d = ((a < b) and (b < c)) or (not(c == 1) and (a != 20)) print(d) - ✔✔False Write the Python code to evaluate the square root of a number. - ✔✔from math import * #if the number is less than zero print error and don't calculate if number < 0 print("error")

if the number is greater than zero go through calculations

else: number = int(input("Enter a number: ")) print("The square root of", number, "is", sqrt(number))

if n % num == 0: count += 1 print(n, end=', ') n [ Select ] print("\nThere are {} numbers evenly divisible by {}".format(count, num)) Example correct output (using input 20): Please enter a positive integer between 1 and 100: 2020, 40, 60, 80, 100, There are 5 numbers evenly divisible by 20 - ✔✔= 1 while += 1 Which of the following is a true statement? Computing is transforming all of engineering Computer programming is an element of engineering on its own All of the other answers are true

Computer programs are a fundamental tool across all of engineering - ✔✔All of the other answers are true Which of the following are valid variable names? Please select all that apply. ENGR102_is_tons_of_fun estimated-pi x_ 2nd_entry temp My_Name - ✔✔ENGR102_is_tons_of_fun x _temp My_Name Which of the following results in a Boolean value of True for variable x? Please select all that apply. a = 50x = a % 2 == 0 a = 5b = 10x = b > a

print("Three") elif a // b == 1: print("Four")if a > 3 and b < 5: print("Five") else: print("Six") print("Seven") - ✔✔Four Five Seven How many iterations will the following loop execute? x = 1 while x < 10: print(x) x += 2 - ✔✔ 5 What is the output of the following code? x = 2 y = 'A' for i in range(10): x *= 2 y += y

if x > 6: break print(x, y) - ✔✔ What is the output of the following code? grades = [90, 95] for i in range(5): grades.append(100 - i) print(len(grades), grades[5]) - ✔✔7 97 Which of the following will NOT result in an error? Please select all that apply. Start with the following: my_list = [1, 2, 3, 4, 5] print(my_list[5]) x = 6my_list += x my_list += [6]

print('BTHO Bama!') - ✔✔BTHO Mizzou! In a hierarchy, a node without children is called a "seed" T or F - ✔✔False Individual elements of a hierarchy are often called "nodes" T or F - ✔✔True In top-down program design, continue to break down the problem into smaller steps until implementing a concept will take just a few lines of code T or F - ✔✔true In a hierarchy, the "root" node has no parents and many children T or F - ✔✔True Top-down design should usually be my first way of approaching a programming problem T or F - ✔✔True