A byte is made up of eight
Ask Expert

Be Prepared For The Toughest Questions

Practice Problems

A byte is made up of eight

SECTION A

Answer all the questions in this section.

1. A byte is made up of eight __________.

a. CPUs

b. instructions

c. variables

d. bits

2. In Python, what does the "//" operator do in the expression 6 // 4?

a. It performs an exponentiation to the 4th power.

b. It returns a remainder or modulus.

c. It returns a whole number as a result.

d. It returns a float as a result of division.

3. What is the value of the following Python expression: 3**(5//2)%2-1 ?

a. 0

b. 1

c. the expression is invalid

d. -1

4. Which of the following are valid variable names?

a. result!

b. weight

c. _height

d. secondResult

e. 2MoreToGo

f. second Result

5. What is the output of the following code?


a. It doesn’t generate any output.

b. 1

2

4

c. 4

d. 1

2

3

4

6. Which Boolean value does this Python expression evaluate to?


a. True

b. False

c. None

7. What is the output of the following program?


a. GeeksforGeeks

b. GFG

c. GFG GeeksforGeeks

d. Compilation error

8. When is the finally block statements executed?

a. When a specific condition is satisfied

b. When there is an exception in try block

c. When there is no exception in try block

d. always

9. Which of the following are true of Python dictionaries?

a. All the keys in a dictionary must be of the same type.

b. When you want to retrieve a specific value from a dictionary, you use the key that is associated with that value.

c. Dictionaries are mutable objects.

d. Elements in dictionary are sorted.

10. What’s the output of the code snippet in the figure?


a. *walking*

b. Woof!

c. Arff!

d. CanineError: Dog malfunction

SECTION B

Read what is required from each question carefully and answer all parts of the question. Explain your answer and give an appropriate example.

1. Assume that setA is a set that contains the following elements: 15, 1, 3, 8, 17, and 21. Assume that setB is a set that contains the following elements: 4, 8, 16, 2, 3, and 21. What are the values in the following sets?

a. setA ^ setB

b. setA – setB

c. setA.union(setB)

d. setA & setB 

2. Construct truth table for the following Boolean expressions: (A or B) and not B

3. The Python file, named apple.py contains the following segment of code:


a. On line 9, = appears. What does this do?

b. On line 4, == appears. What does this do?

c. What will line 11 cause the script to print?

d. What will line 12 cause the script to print?

e. What is the purpose of the function apple?

4. What happens when the programmer forgets to update the loop control variable in a while loop? Explain with example.

5. What is the difference between floating-point and integer division? Explain with example.

SECTION C

Read what is required from each question carefully and answer all parts of the question.

1. Construct a program that has a function that receives a list and calculates the sum of the values in that list. 


2. Construct a program that has a function which receives a string from the user and creates a dictionary that maps each character in the given string to its frequency, that is, how many times that character appears in the given string.

For example, if the given string is "book", the program creates the following dictionary:

b : 1

o : 2

k : 1


3. Write a code segment that opens a file for input and prints the number of four-letter words in the file. If the file cannot be opened catch the exception and display appropriate message. 

4. Write a Python class named Circle constructed by a radius and two methods which will compute the area and the perimeter of a circle. 


Hint
ComputerA byte is the basic unit of information in computer processing and storage. A byte contains 8 bits, each of which comprises of a 0 or 1. A byte can denote the corresponding of a single character, such as the letter, a comma, or a percentage sign, or it can denote a number from 0 to 255...

Know the process

Students succeed in their courses by connecting and communicating with
an expert until they receive help on their questions

1
img

Submit Question

Post project within your desired price and deadline.

2
img

Tutor Is Assigned

A quality expert with the ability to solve your project will be assigned.

3
img

Receive Help

Check order history for updates. An email as a notification will be sent.

img
Unable to find what you’re looking for?

Consult our trusted tutors.

Developed by Versioning Solutions.