Log in
Sign up for FREE
arrow_back
Library

Files Test

star
star
star
star
star
Last updated about 2 years ago
20 questions
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
Question 17
17.

Question 18
18.

Question 19
19.

1
Question 1
1.

Question 2
2.

Question 3
3.

Question 4
4.

Question 5
5.

Question 6
6.

Question 7
7.

Question 8
8.

Question 9
9.

Question 10
10.

Question 11
11.

Question 12
12.

Question 13
13.

Question 14
14.

Question 15
15.

Question 16
16.

What action would the code below perform? f = open('while.dat') while True: line = f.readline() if not line: break
a. Opens a file and reads in all values present.
b. Opens a file and reads in the first value only.
c. Opens a file and reads in the last value only.
d. The code does nothing.
e. There is no output due to a runtime error.
What action would the code below perform? f = open("for.dat","r"); times = int( f.readline() ) b = sys.maxsize for x in range(0, times): v = int( f.readline() ) if b > v : b = v
a. Reads in and adds up all values present in the file.
b. Reads in all values in the file and finds the biggest.
c. Reads in all values in the file and finds the smallest.
d. The code does nothing.
e. There is no output due to a runtime error.
What action would the code below perform? f = open("for.dat","r"); val = int( f.readline() )
a. Opens a file and reads in all values present in the file.
b. Opens a file and reads in the first value only.
c. Opens a file and reads in the last value only.
d. The code does nothing.
e. There is no output due to a runtime error.
Question 20
20.

What is output by the code below? cat = "Q R S T U V" dog = cat.split() print(dog[2])
a. Q R S T U V
b. Q
c. S
d. V
e. R
Which of these can be used to convert a string / text value into a numeric value?
a. sys.maxsize
b. ~sys.maxsize
c. int()
d. str()
e. len()
What is output by the code below? cat = "Q R S T U V" dog = cat.split() print(dog[7])
a. Q R S T U V
b. Q
c. S
d. V
e. error
Which of these represents the smallest numeric value in Python?
a. sys.maxsize
b. ~sys.maxsize
c. int()
d. str()
e. len()
Question 5: Which of these can be used to convert a numeric value into a string / text value?
a. sys.maxsize
b. ~sys.maxsize
c. int( )
d. str( )
e. len( )
Question 6: Which of these can be used to determine how many values are present in a list?
a. sys.maxsize
b. ~sys.maxsize
c. int( )
d. str( )
e. len( )
Question 7: Which of these represents the largest numeric value in Python?
a. sys.maxsize
b. ~sys.maxsize
c. int( )
d. str( )
e. len( )
Question 8: What action would the code below perform? f = open('while.dat') while True: line = f.readline() if not line: break print( int( line ) )
a. Opens a file and reads in and prints all values present.
b. Opens a file and reads in the first value only.
c. Opens a file and reads in the last value only.
d. The code does nothing.
e. There is no output due to a runtime error.
What action would the code below perform? f = open("for.dat","r"); times = int( f.readline() ) b = 0 for x in range(0, times): b = b + int(f.readline())
a. Reads in and adds up all values present in the file.
b. Reads in all values in the file and finds the biggest.
c. Reads in all values in the file and finds the smallest.
d. The code does nothing.
e. There is no output due to a runtime error.
Which type of loop would you use to read from a file with an unknown number of items?
a. while
b. for
c. do while
d. A & B only
e. A, B, and C
Which type of loop would you use to read from a file with a known number of items?
a. while
b. for
c. do while
d. A & B only
e. A, B, and C
What is output by the code below? cat = "Q R S T U V" dog = cat.split( ) print( dog[0] )
a. Q R S T U V
b. Q
c. S
d. V
e. R
What action would the code below perform?
f = open("for.dat","r");
times = int( f.readline() )
for x in range(0, times):
print( f.readline() )
Opens a file and reads in and prints times numbers.
Opens a file and reads in the first value only.
Opens a file and reads in the last value only.
The code does nothing.
There is no output due to a runtime error.
What action would the code below perform?
f = open("for.dat","r");
times = int( f.readline() )
for x in range(0, times):
f.readline()
Opens a file and reads in times numbers.
Opens a file and reads in the first value only.
Opens a file and reads in the last value only.
The code does nothing.
There is no output due to a runtime error.
What action would the code below perform?

f = open("for.dat","r");
Open a file and reads in all values present in the file.
Open a file and reads in the first value only.
Open a file and reads in the last value only.
The code opens the file.
There is no output due to a runtime error.
What is output by the code below?

cat = "44"
print( int(cat) * 2 )
4444
44 44
88
44 2
cat cat
Question 20: What action would the code below perform? python f = open("for.dat","r"); times = int(f.readline()) b = ~sys.maxsize for x in range(0, times): v = int(f.readline()) if b < v : b = v
a. Reads in and adds up all values present in the file.
b. Reads in all values in the file and finds the biggest.
c. Reads in all values in the file and finds the smallest.
d. The code does nothing.
e. There is no output due to a runtime error.