Edhesive Units 1-3 Anwsers (Computer Science)

¡Supera tus tareas y exámenes ahora con Quizwiz!

Which of the following is used to show not equals?

!=

Some information may be lost when it is converted.

#

Which of the following is NOT a legal variable name?

%information

Which of the following calculates to 10?

(3 * 6 + 2) /2

Which of the following calculates to 19?

(3 * 6) + 2 /2

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

**

Consider the following number sequence: -1 2 -3 4 -5 6 __ __ __ What are the next three numbers in the sequence?

-7 8 -9

What is output by the following? print ("/\\") print ("\\/")

/\ \/

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

0 1 2

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

0, 1, ... 7

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

0.0 <= r < 5

In the next five years there are expected to be over _______ unfilled jobs in the US in CS

1 Mil

What is output? Select all that apply. c = 0 while (c < 5): c = c + 1 print (c)

1,2,3,4,5

Consider the following code: x = 9 y = -3 z = 2 print ((x + y)*z) What is output?

12

Consider the following code: x = 5 x = x * 3 print (x) What is output?

15

In __________ the first computer ran a program from memory.

1948

Consider the following code? x = 17 y = 5 print (x % y) What is output?

2

What is output? print (12 % 5)

2

Check ALL of the correct answers. What would the following FOR loop print? for i in range(2, 4): print (i)

2,3

What is output? Select all that apply. c = 6 while (c > 0): print (c) c = c - 2

2,4,6

What is output by the following line of code? print (5+9*2)

23

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

240

How big is a terabyte?

2^40

What is output? print (3 % 15)

3

x = 10 if ( x > 10 ): print (1) elif ( x < 10 ): print (2) elif ( x >= 10 ): print (3) else: print (4)

3

x = 21 if (x > 21): print (1) elif (x < 21): print (2) else: print (3)

3

x = 21 if (x > 21): print (1) elif (x < 21): print (2) else: print (3)

3

Which of the following calculates to 12?

3 * ((6 + 2) /2)

Consider the following code: val = 1 sum = 0 while (val < 10): val = val * 2 sum = sum + val print (sum) What is output?

30

Consider the following: calc = 3*5 + 4**2 - 1 What is the base for the exponent?

4

What is output by the following code? x = 19 y = 5 print (x % y)

4

What is output? x = 8 % 2 if ( x > 10 ): print (1) elif ( x > 5 ): print (2) elif (x > 1 ): print (3) else: print (4)

4

Consider the following code: x = 2 while (x < 11): x = x * 2 print (x) What is output?

4 8 16

Consider the following code: x = 9 y = -2 z = 2 print (x + y * z) What is output?

5

Which of the following is NOT a correct variable assignment?

5 + y = x

In the following circle command the radius is _____________. canvas.draw_circle ((140, 100), 50, 15, "Black")

50

What is 7 % 24

7

Assume the user types in 7 and 10. What is output by the following? num1=input("Enter a number: ") num2=input("Enter a number: ") print (num1 +num2)

710

What is output? x = 2 y = 3 print (x * y + 2)

8

Consider the following code: a = 3 b = 2 print (a ** b) What is output?

9

What is output by the following? print (type("95"))

<type 'str'>

What is output by the following code? print type ("67") print type (67) pritn type (67.0)

<type 'str'> <type 'int'> <type 'float'>

The following code is intended to test if x is NOT less than 17. Fill in the correct symbol: if (x ____ 17):

>=

To test if x is greater than or equal to y: if (x ___ y):

>=

What is output by: print ("A") print ("\tB) print ("C")

A B C

What is output if the user types in 13? Click all that apply.

ABD

For questions 1-3, consider the following code: x = int (input ("Enter a number: ")) if (x != 8): print ("A") if (x >= 10): print ("B") if (x < 10): print ("C") if (x % 2 == 1): print ("D") What is output if the user types in 9? Click all that apply.

ACD

The code: sum = sum + num is used to ____________.

Add up a list of numbers.

___________ created the idea of a general Purpose Computing Machine.

Alan Turing

__________ data is what is translated to digital format so it can be stored in a computer

Analong

Storing a value in a variable

Assignment

Why do we do number calculations in programming?

Because computers can do calculations humans can't.

What is output if the user types in 8? Click all that apply.

C

Which of the following carries out the commands in programs?

CPU

Which of the following in NOT an output device?

Camera

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

Charles Babbage

What is the correct order for the steps the compiler uses in translating code?

Check for mistakes, Translate commands to machine language, Run the commands

What do we call notes in computer code for the programmer hat are ignored by the computer?

Comments

Which of the following about computers is NOT true?

Computing devices translate digital to analog information in order to process the information.

Computer Science lets people

Create new software/Solve problems/Communicate

Consider the following command: canvas.draw_circle(( A, B), C, D, E) Which represents the line thickness?

D

The following statement draws a ______________ line. canvas.draw_line ((140, 140), (100, 100), 4, "Black")

Diagonal Line

The __________ was the first all electronic computer.

ENIAC

Consider the following code: x = int(input("Enter a number: ")) print (x) What happens if the user types in A?

Error: an int variable cannot store a String.

_________ are special output characters marked with a \

Escape characters

The print command in Python can be written as PRINT or print (TorF)

False

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

Finding mode

For questions 2-4, consider the following code: if (month ==9): if(day > 15): print ("Second half of the month") else: print ("First half of the month") else: print("Not in September") What is the output if month = 9 and day = 14?

First half of the month

__________ is based on a set of very specific rules for communicating

Formal Language

__________ is designed to be very clear and work consistently every time it is used

Formal Language

What is output by the following lines of code if we input the name "Sally"? n=input("What is your name?") print ("Hello there " + n)

Hello there Sally

What is output by the following? Assume the user enters Sally and John x=input("What is your name?") y=input("What is your friend's name?") print ("Hi+x+" and " + y)

Hi Sally and John

What is output by the following line of code? print ("I\tLove Python")

I Love Python

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) Try running this program a few times using the following numbers as input: 16, 25, 36, 49. What does the program do?

It finds the square root of the input number.

The following code is intended to find the average of three numbers entered from the keyboard. What is wrong with the code? print ("Enter 3 numbers: ") n1 = float(input ("Enter a number: ")) n2 = float(input ("Enter a number: ")) n3 = float(input ("Enter a number: ")) print (n1 + n2 + n3 /3)

It is missing ( ) in the last line

What is wrong with the following line of code: print (Hello World)

It needs ' around Hello World

What is wrong with: num1=int(input("Enter a number: ")) num2=int(input("Enter a number: ")) num3=int(input("Enter a number: ")) print ("The average is: " + (num1 + num2 + num3)/3)

It needs a str command

__________ created the earliest programmed machine.

Konrad Zuse

Which of the following are true about main and secondary memory?

Main memory is short term memory used by the CPU in processing commands, secondary memory is more permanent and used for storage

What is an IF statement used for? Select all that apply.

Make True/ False decisions Select between options in a program

_________ is what we use to communicate day to day

Natural Language

Does it matter if you use " or ' with the print command?

No

What is output if month = 11 and day = 14?

Not in September

A symbol that defines a math calculation is:

Operator

What are the two reasons we analyze algorithms?

Predict performance Make decisions about what algorithm to use

What does the following loop do? val = 0 sum = 0 while (val < 10): val = val + 1 sum = sum + val print (sum)

Print the sum of the numbers from 1 to 10.

Which of the following are true about algorithms? (You may select more than one)

Produce a result Have clear instructions Operations that can be done by a computer Stop in a finite amount of time Have an order

Instructions written in code that a computer follows are called:

Program

What is input

Pulling information into the computer

Which of the following would NOT work for creating a color?

RGB (10, 200, 155)

Which color is created by: RGB (255, 0, 0)

Red

How can you change to code so that the frame flashes different grays with no color?

Replace the r, g, b definition as follows: r = random.randint(0,255) #g = random.randint(0,255) #b = random.randint(0,255) randRGBColor = "RGB( " + str(r) + "," + str(r) + "," + str(r) + ")"

How can you change to code so that the frame flashes shades of red, with no greens or blues?

Replace the randRGBColor line with: randRGBColor = "RGB( " + str(r) + "," + str(0) + "," + str(0) + ")"

hat is output if month = 9 and day = 21?

Second half of the month

The programs that run on a computer are called:

Software

What is one downside of converting analog information to a digital format?

Some information may be lost when it is converted.

Which of the following is NOT true about Strings?

Stored in 1 byte of memory

Colors in graphics are represented by a ____________ data type.

String

Color codes are stored as:

Strings

The two basic categories of variable data types are:

Strings and numbers

What is the CPU

The central processing unit, it acts as the brain of the computer and carries out commands.

Consider the following code: val = 0 while (val < 10): val = val - 1 print (val) What is the error?

The loop will not stop since val is counting the wrong direction.

This code accepts a word as input, and then prints that word to the screen. w=input ("Enter a word: ") print (w) What happens if you type a number instead of a word?

The number is printed

What is the output for the following? x = 7 print ("The number is: " + str(x * 2))

The number is: 14

if (x > 5 AND x <= 10): print (OK) Click all the mistakes that apply:

The print (OK) should be print ("OK") AND should be and

What does the % find?

The remainder

Which of the following is NOT true about variables

The value stored by a variable cannot change

color = input("What color? ") if (color == "green"): print ("Correct") else: print ("Nope") elif (color == "red"): print ("Correct) What happens when it is run?

There is an error, the else should be after the elif

Consider the following code: x = 0 while (x > -13): x = x - 2 print (x) What is the error?

There is no error, the code runs without problems.

Consider the following code: x = 0 while (x != 19): print (x) What is the error?

There is no x = x + 1 so the loop will never stop.

Which of the following is NOT true about the random functions.

They are contained in the math module.

You are writing a loop to print a word entered from the keyboard 15 times. Which of the following is true?

This will be a loop stopped by counting

When do you NOT use a String?

To store decimal values.

When do you use an else statement?

To tell what will happen when an if-statement is false.

What is output by the following? print ("Twinkle, \ttwinkle, \tlittle star")

Twinkle, twinkle, little star

What is output by the following? Assume the user enters 5 and 4 x = input ("Enter a number: ") y = input ("Enter a number: ") print ("Values: " + x + y)

Values: 54

A name given to a spot in memory is called

Variable

When do we use numbers instead of strings?

When you need to do calculations

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 0 for the second number?

ZeroDivisionError: float division by zero

What is returned by the code: range (5, 100, 25) ?

[5, 30, 55, 80]

Which of the following is true? a = 1 b = 10

a < b and a != b

Which of the following correctly does the calculation 76?

a = 7 ** 6

Consider the following code: x = input ("What year is it?") print x The value stored in x is:

a String

using a microphone to record a sound of your computer is an example of:

analog to digital conversion

The following code could be rewritten using: if (x > 12): if ( x < 34):

and

To test if a variable is between two numbers you would use:

and

Consider the following code: x = "apple" y = x z = "banana" print (x + " " + y + "\n" + z)

apple apple banana

Consider the following code - what is output? print min("whom", "carton", "landform", "apron", "deposit", "become")

apron

Which variable name is the best to hold the area of a rectangle?

area

Which of the following is true? a = 15 b = 10

b >= a or a > b

What color is "RGB(0, 0, 0)"?

black

Which of the following is NOT an acceptable way to create a color:

blue

Consider the following output: 2 3 4 5 6 Put the following code in order from first step to last step of execution. Select the answer that best simulates how to get the printed order above. print (c) while ("while (c < 6):", B) c = c + 1 c = 1

c = 1 while ("while (c < 6):", B) c = c + 1 print (c)

Which loop prints the numbers 1, 2...100?

c = 1 while (c <= 100): print (c) c = c + 1

Which of the following will print a vertical line?

canvas.draw_line ((100, 140), (100, 40), 4, "Black")

Which of the following correctly draws a point on the screen? canvas.draw_pix

canvas.draw_point((123, 125), "Red")

Which of the following will output a box?

canvas.draw_polygon([(150, 50),(150, 150),(50, 150),(50, 50)], 1, "Black")

Consider the following code: print ("computer" + "science") What is output?

computerscience

c = c + 1 is called a(n) _____________.

count variable

Which of the following is NOT a data type in Python?

decimal

Using ans LCD projector to show an online video to a group of people is an example of:

digital to analog conversion

Which of the following is NOT true about algorithms?

do number calculations

What statement will be best to draw a square?

draw_line

Which command correctly draws Strings on the screen?

draw_text

Which function would you use to make sure a distance found in a calculation is positive

fabs

You need to make sure a number the user types in is positive - which of the following functions would you use?

fabs

What data type does the pow function return?

float

What color is (255, 0, 255)

fuchsia

A ____________ is a set of commands which can be run by calling it by name.

function

Consider the following code: x = random.randint (1, 100) Â The randint is a ____________.

function

Write the code to test if the variables num1 and num2 are the same.

if ( num1 == num2 ):

Write the code to test if the number 78 is stored in the variable text1:

if ( text1 == 78 ):

Write the code to test if x is greater than or equal to 2.

if ( x >= 2 ):

The following code should be rewritten as if (50 > x > 40)

if (50 > x and x > 40):

Which of the following is a correction for: if (90 <= x <= 100):

if (90 <= x and x <= 100):

Write the code to test if num1 and num2 are the same.

if (num1 == num2)

Write the code to test if the number in the variable text1 is greater than 15.

if (text1 > 15):

Which of the following correctly tests if a number equals 90 or 100?

if (x == 90 or x == 100):

The following code will not compile â€" which of the following is correct? if (x >= -10 and <= 10): print ("In range")

if (x >= -10 and x <= 10):

_______ is information the user sends to the computer

input

What command is used to change a string into a number

int

What is the best variable name to hold your English letter grade.

letterGrade

Which of the following is a correct variable name?

lowTemperature

Short term memory used by the CPU

main memory

Which of the following correctly inputs two numbers and print the sum?

n1 = int(input("Enter a number: ")) n2 = int(input("Enter a number: ")) print("The answer is: " + str(n1+n2))

Which of the following lines of code correctly inputs a number?

n=int(input("Enter a value: "))

What is the output for the following? x = 7 print ("The number is: " + x * 2)

none, there is an error

The following Venn diagram could represent which of the following Boolean statements?

not

Ask the user to input a number less than 100. Print all the numbers from that number to 100. Which loop correctly does this?

num = int (input("Enter a number between 1 and 100: ")) c = num while (c <= 100): print (c) c = c + 1

Write a program that asks the user for their name and how many times to print it. If I enter Ada and 3 it should print: Ada Ada Ada Which loop correctly does this:

num = int (input("Enter a number: ")) name = input ("Enter your name: ") c = 1 while (c <= num): print (name) c = c + 1

x = 9 % 2 if (x == 1): print ("ONE") else: print ("TWO")

one

Which of the following controls computer memory?

operating system

When the computer translates digital information to information humans can use, it is called _______

output

A _____________ is the information sent to a function

parameter

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

pow

What is the Python command that can be used to display text and numbers on the screen?

print

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))

Which line of code outputs the decimal portion of a float stored in the variable x?

print (x - int(x))

Which of the following is NOT an input device?

printer

Which of the following will correctly output: I know there's a proverb which that says "To err is human," but a human error is nothing to what a computer can do if it tries. - Agatha Christie

quote = "\"To err is human,\"" print ("I know there's a proverb which that says \n"+ quote + "\nbut") print ("a human error is nothing to what a computer") print ("can do if it tries.\n\n- Agatha Christie")

How can you change to code so that the frame flashes greens and blues (and no reds)?

r = random.randint(0,0)

Which of the following is NOT a function?

random

To generate whole numbers between and including -10 to 10 you would use:

random.randint(-10, 10)

Which command tells the FOR loop what to count by?

range

What is output by the following? print("she sells \nseashells") print("by the seashore")

she sells seashells by the seashore

Programs that run on hardware are called?

software

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

sqrt

You need to find the square root of a value, which of the following methods would you use?

sqrt

Which command converts a number to a string

str

Which of the following is a legal variable name?

temperatureAM

Which of the following correctly stores 45 squared in the variable x?

x = 45 x = x ** 2

To print the even numbers between -20 and 20 you would use:

x = x + 2

x = int(input("Input an integer: ")) if (x >= 0): print("Yay!") else: print("Boo!") It outputs "Yay!" if the value is positive and "Boo!" if the value is negative. Change the condition, so that it only outputs "Yay!" if the value is non-negative (i.e. zero or positive) and even.

x >= 0 and x % 2 == 0


Conjuntos de estudio relacionados

UNIT 2 - (ch. 5-8), Chp 5-7 Exam Review

View Set

HW3: Homework - Ch. 3: Supply and Demand

View Set