1.7-1.9 questions Flashcards

1
Q

Which of the following is NOT true about variables?

  • Variable names can be words: such as temperature or height.
  • The value stored by a variable cannot be changed after it is assigned.
  • Variables are a name for a spot in the computer’s memory.
  • The value stored by a variable can be changed after it is assigned.
A
  • The value stored by a variable cannot be changed after it is assigned.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

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)

17
710
No output, there is an error.
71

A

710

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Which command converts a number to a string?

num()

int()

str()

word()

A

str()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Which of the following is true about strings?

  • They do not let the user type in letters, numbers and words
  • They cannot be stored to a variable
  • An input (unless otherwise specified) will be stored as a string
  • They are used for arithmetic calculations
A
  • An input (unless otherwise specified) will be stored as a string
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is wrong with the following code?

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)

  • The last line should be print(“The average is: (num1 + num2 + num/3))
  • It needs a int() command
  • It needs a str() command
  • The variables should be 1num, 2num, 3num
A

it needs a str() command

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

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

  • n = input(“Enter a value: “)
  • n = str(input(“Enter a value: “))
  • n = int(input(“Enter a value: “))
  • n = num(input(“Enter a value: “))
A
  • n = int(input(“Enter a value: “))
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
\_\_\_\_\_\_\_\_\_\_\_\_\_ data is what is translated to digital format so it can be stored in a computer.
  Digital 
  Binary 
  Secondary 
  Analog
A

Analog

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

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

  • analog to digital conversion
  • main memory
  • output
  • digital to analog conversion
A

analog to digital conversion

How well did you know this?
1
Not at all
2
3
4
5
Perfectly