Edhesive : 2.1 - 2.7

Ace your homework & exams now with Quizwiz!

2.2 Lesson Practice A symbol that defines a math calculation is:

Operator

2.3 Lesson Practice What does the % find?

The remainder

2.4 Lesson Practice Which function would you use to make sure a distance found in a calculation is positive?

fabs

2.2 Code Practice: Question 1

num = int(input("Enter a number: ")) print(num + 1) print(num + 2) print(num + 3)

2.2 Code Practice: Question 2

num1 = float(input("Enter a number: ")) num2 = float(input("Enter a number: ")) num3 = float(input("Enter a number: ")) print('Sum: '+str(num1+num2+num3))

2.4 Code Practice: Question 2

x = float(input('Enter a number: ')) y = int(x) x = x - y print(x)

2.3 Lesson Practice If you are doing modular division with a divisor of 3, what are the only possible answers?

0 1 2

2.1 Lesson Practice __________ invented the Analytical Engine, a machine that did calculations.

Charles Babbage

2.3 Lesson Practice Read the text and complete the questions in the following link from "How to Think Like a Computer Scientist": Operators and Operands.

Complete the assigmnet

2.1 Lesson Practice The __________ was the first all electronic computer.

ENIAC

2.1 Lesson Practice __________ created the earliest programmed machine.

Konrad Zuse

2.1 Lesson Practice In __________ the first computer ran a program from memory.

1948

2.6 Lesson Practice How big is a terabyte?

2^40

2.2 Lesson Practice Which of the following is NOT a correct variable assignment?

5 + y = x

2.3 Lesson Practice What is 7 % 24

7

2.1 Lesson Practice ___________ created the idea of a general Purpose Computing Machine.

Alan Turing

2.3 Lesson Practice Which of the following is NOT a problem modular division is used for?

Finding the mode

2.2 Lesson Practice This program accepts a number as input and raise it to the .5 power (i.e., x ** .5). a = float(input("Enter a number: ")) print (a ** .5) The program is run, using the following numbers as input: 16, 25, 36, 49. The outputs are 4, 5, 6 and 7 respectively. Based on this output, what can you conclude this code does?

It finds the square root of the input number.

2.2 Lesson Practice This program takes two numbers as input, and prints their quotient. a = float(input("Enter a number: ")) b = float(input("Enter a number: ")) print ("Quotient: " + str(a/b)) What is output when when you enter 1 as the second number (regardless of what you enter as a value for the first number)?

The value of a

2.5 Lesson Practice Which of the following is NOT true about the random functions.

They are contained in the math module

2.2 Lesson Practice Which of the following correctly does the calculation 7^6?

a = 7 ** 6

2.3 Code Practice: Question 1

dividend =float(input('Enter the dividend:')) divisor =float(input('Enter the divisor:')) quotient=int(dividend/divisor) remainder=dividend%divisor print('The quotient is: '+str(quotient)) print('and a remainder of: '+str(remainder))

2.7 Code Practice: Question 1

first = int(input("Enter a number: ")) second = int(input("Enter a number: ")) third = int(input("Enter a number: ")) print("Largest: " + str(max(first,second,third)))

2.4 Lesson Practice What data type does the pow function return?

float

2.4 Code Practice: Question 1

import math x = int(input('Enter a number: ')) print(math.sqrt(math.fabs(x)))

2.5 Code Practice

import random a = random.randint(1, 10) b = random.randint(1, 10) answer = a * b print (str(a) + " x " + str(b) + " = " + str(answer))

2.7 Code Practice: Question 2

lat = [40.59, 40.52, 40.621, 40.519, 40.56, 41.265, 40.61, 40.806, 41.259, 41.265, 41.264, 41.264, 41.259, 41.262, 41.263] lon = [69.532, 69.419, 69.354, 69.263, 69.478, 70.805, 69.706, 70.331, 70.815, 70.823, 70.815, 70.81, 70.824, 70.811, 70.811] print("Farthest north = " + str(max(lat))) print("Farthest west = " + str(max(lon))) print("Farthest south = " + str(min(lat))) print("Farthest east = " + str(min(lon)))

2.4 Lesson Practice Which function would you use to raise a number to an exponent?

pow

2.2 Lesson Practice Which of the following correctly prints the following calculation if x is 17 and y is 5? Sum is: 22

print ("Sum is: " + str(x + y))

2.4 Lesson Practice Which function would you use to find the measure of the side of a square if you already know the area?

sqrt

2.5 Lesson Practice What are the possible output of the following? print (random.randint(0, 7))

0, 1, ... 7

2.2 Lesson Practice What is output? a = 10 b = 23 print (a + b * a)

240

2.2 Lesson Practice What is the symbol for exponent?

**

2.5 Lesson Practice What are the possible output of the following? print (random.random()*5)

0.0 <= r < 5

2.2 Lesson Practice Which of the following calculates to 19?

(3 * 6) + 2 /2

2.2 Lesson Practice Watch the videos, read the text and complete the questions at the following link from "How to Think Like a Computer Scientist": Order of Operations (Links to an external site.) In this video, you will see "Integer Division" with the symbol //. Integer division is a different process from modular division. It it does the division problem between two numbers and only displays the whole number portion, not the remainder. This is essentially the opposite of modular division. Examples: 5 // 3 = 1 (3 goes into 5 once) 10 // 2 = 5 (5 goes into 10 two times) 19 // 4 = 4 (4 goes into 19 four times)

Do the assigmnet


Related study sets

Troubleshooting Digital Television Service Introduction

View Set

First Semester Mix-Tape 🔥 #fire 🔥🔥 !!!!

View Set

Excel- Chapter 12: Creating Charts

View Set

Reading 17. International Trade and Capital Flows

View Set

LS Ch 5 - Strategic Capacity Planning for Products & Services

View Set

Cognitive: Chapter 12/13 Music Cog Quiz

View Set

Chapter 36: Management of Patients With Immune Deficiency Disorders - ML4

View Set

Chapter 7: Love and Romantic Relationships

View Set

Vocab (Allocate, Ardent, Assiduous, etc.)

View Set