SOLUTIONS FOR THE FIRST REVIEW SESSION COSC 1306 Fall 2017 First - - PowerPoint PPT Presentation

solutions for the first review session
SMART_READER_LITE
LIVE PREVIEW

SOLUTIONS FOR THE FIRST REVIEW SESSION COSC 1306 Fall 2017 First - - PowerPoint PPT Presentation

SOLUTIONS FOR THE FIRST REVIEW SESSION COSC 1306 Fall 2017 First Question Which of the following statements are true or false? Interpreted languages produce faster code than compiled languages. First Question Which of the


slide-1
SLIDE 1

SOLUTIONS FOR THE FIRST REVIEW SESSION

COSC 1306 Fall 2017

slide-2
SLIDE 2

First Question

Which of the following statements are true or false?

 Interpreted languages produce faster code

than compiled languages.

slide-3
SLIDE 3

First Question

Which of the following statements are true or false?

 Interpreted languages produce faster code

than compiled languages.

FALSE

slide-4
SLIDE 4

First Question

Which of the following statements are true or false?

 Having a large disk drive allows us to store

more data on our computer.

slide-5
SLIDE 5

First Question

Which of the following statements are true or false?

 Having a large disk drive allows us to store

more data on our computer.

TRUE

slide-6
SLIDE 6

First Question

Which of the following statements are true or false?

 Algorithms always provides the correct

answer but can take forever.

slide-7
SLIDE 7

First Question

Which of the following statements are true or false?

 Algorithms always provides the correct

answer but can take forever.

FALSE

slide-8
SLIDE 8

First Question

Which of the following statements are true or false?

 The main memory is the part of the

computer that executes your programs.

slide-9
SLIDE 9

First Question

Which of the following statements are true or false?

 The main memory is the part of the

computer that executes your programs.

FALSE

slide-10
SLIDE 10

First Question

Which of the following statements are true or false?

 A three-bit binary number will never

represent a number bigger than three.

slide-11
SLIDE 11

First Question

Which of the following statements are true or false?

 A three-bit binary number will never

represent a number bigger than three.

FALSE

slide-12
SLIDE 12

First Question

Which of the following statements are true or false?

Python expressions always return a value.

slide-13
SLIDE 13

First Question

Which of the following statements are true or false?

 Python expressions always return a value.

TRUE

slide-14
SLIDE 14

First Question

Which of the following statements are true or false?

 Having a large disk drive allows us to store

more data on our computer.

slide-15
SLIDE 15

First Question

Which of the following statements are true or false?

 Having a large disk drive allows us to store

more data on our computer.

TRUE

slide-16
SLIDE 16

First Question

Which of the following statements are true or false?

Programs without comments are harder to

read by humans.

slide-17
SLIDE 17

First Question

Which of the following statements are true or false?

Programs without comments are harder to

read by humans.

TRUE

slide-18
SLIDE 18

First Question

Which of the following statements are true or false?

 In Python, Total and total are two

different variable names.

slide-19
SLIDE 19

First Question

Which of the following statements are true or false?

 In Python, Total and total are two

different variable names.

TRUE

slide-20
SLIDE 20

First Question

Which of the following statements are true or false?

 The Python 3 input() function always

returns a string.

slide-21
SLIDE 21

First Question

Which of the following statements are true or false?

The Python 3 input() function always returns

a string.

TRUE

slide-22
SLIDE 22

First Question

Which of the following statements are true or false?

You cannot run Python programs on a

computer that does not have the Python interpreter installed.

slide-23
SLIDE 23

First Question

Which of the following statements are true or false?

You cannot run Python programs on a

computer that does not have the Python interpreter installed.

 TRUE

slide-24
SLIDE 24

Second question

 What are the values of the variables a, b, c, and

d after the following Python code is executed?

a = 6//7

b = "3" + "4" c = 1/2 + 2 d = 2**1**2

slide-25
SLIDE 25

Second question

What are the values of the variables a, b, c, and d after the following Python code is executed?

 a = 6//7

b = "3" + "4" c = 1/2 + 2 d = 2**1**2

 a = 0

slide-26
SLIDE 26

Second question

What are the values of the variables a, b, c, and d after the following Python code is executed?

 a = 6//7

b = "3" + "4" c = 1/2 + 2 d = 2**1**2

 a = 0

b = '34'

slide-27
SLIDE 27

Second question

What are the values of the variables a, b, c, and d after the following Python code is executed?

 a = 6//7

b = "3" + "4" c = 1/2 + 2 d = 2**1**2

 a = 0

b = '34' c = 2.5

slide-28
SLIDE 28

Second question

What are the values of the variables a, b, c, and d after the following Python code is executed?

 a = 6//7

b = "3" + "4" c = 1/2 + 2 d = 2**1**2

 a = 0

b = '34' c = 2.5 d = 2

Because 2**1**2 = 2**(1**2)

slide-29
SLIDE 29

Third question

 Convert the following five binary numbers to

know something about yourself.

 011 = ____  001 = ____  011 = ____  011 = ____  111 = ____

slide-30
SLIDE 30

Third question

 Convert the following five binary numbers to

know something about yourself.

 011 = 2 + 1 = 3  001 = ____  011 = ____  011 = ____  111 = ____

8421

slide-31
SLIDE 31

Third question

 Convert the following five binary numbers to

know something about yourself.

 011 = 2 + 1 = 3  001 = 1  011 = ____  011 = ____  111 = ____

8421

slide-32
SLIDE 32

Third question

 Convert the following five binary numbers to

know something about yourself.

 011 = 2 + 1 = 3  001 = 1  011 = 2 + 1 = 3  011 = 2 + 1 = 3  111 = ____

slide-33
SLIDE 33

Third question

 Convert the following five binary numbers to

know something about yourself.

 011 = 2 + 1 = 3  001 = 1  011 = 2 + 1 = 3  011 = 2 + 1 = 3  111 = 4 + 2 + 1 =7

8421 You are 31337 = ELEET = ELITE

slide-34
SLIDE 34

Fourth question

Which Boolean expression is represented by the following circuit?

q r p

slide-35
SLIDE 35

Fourth question

Which Boolean expression is represented by the following circuit?

 p or (q and r)

q r p

  • r

and

slide-36
SLIDE 36

Fifth question

 Which of these Python expressions are

equivalent?

a + (b*c)

a + b*c

(a*b)**2

a*b**c

a + b/c

(a + b)/c

a*b/c*d

(a*b)/c*d

slide-37
SLIDE 37

Fifth question

 Which of these Python expressions are

equivalent?

a + (b*c)

a + b*c

 EQUIVALENT

(a*b)**2

a*b**c

a + b/c

(a + b)/c

a*b/c*d

(a*b)/c*d

slide-38
SLIDE 38

Fifth question

 Which of these Python expressions are

equivalent?

a + (b*c)

a + b*c

 EQUIVALENT

(a*b)**2

a*b**c

 NOT EQUIVALENT

a + b/c

(a + b)/c

a*b/c*d

(a*b)/c*d

slide-39
SLIDE 39

Fifth question

 Which of these Python expressions are

equivalent?

a + (b*c)

a + b*c

 EQUIVALENT

(a*b)**2

a*b**c

 NOT EQUIVALENT

a + b/c

(a + b)/d

 NOT EQUIVALENT

a*b/c*d

(a*b)/c*d

slide-40
SLIDE 40

Fifth question

 Which of these Python expressions are

equivalent?

a + (b*c)

a + b*c

 EQUIVALENT

(a*b)**2

a*b**c

 NOT EQUIVALENT

a + b/c

(a + b)/c

 NOT EQUIVALENT

a*b/c*d

(a*b)/c*d

 EQUIVALENT

slide-41
SLIDE 41

Sixth question

 You are asked to reorder the following Python

statements so they form a program computing the cost per ounce of an item: price = float(input("Enter the price: ")) print("Its cost per ounce is $%.2f" % unitCost) nOunces = float(input("Enter the number of

  • unces of product: "))

unitCost = price/nOunces

slide-42
SLIDE 42

Sixth question

 You are asked to reorder the following Python

statements so they form a program computing the cost per ounce of an item: price = float(input("Enter the price: ")) nOunces = float(input("Enter the number of

  • unces of product: "))

unitCost = price/nOunces print("Its cost per ounce is $%.2f" % unitCost)