0% found this document useful (0 votes)
5 views

Assignment-W6

The document contains an assignment for an online certification course on the Internet of Things from IIT Kharagpur, featuring 15 multiple-choice questions related to Python programming and Raspberry Pi. Each question includes a statement, options, the correct answer, and a detailed solution. The assignment assesses knowledge on topics such as Python syntax, library usage, file handling, and Raspberry Pi configuration.

Uploaded by

23uea028
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Assignment-W6

The document contains an assignment for an online certification course on the Internet of Things from IIT Kharagpur, featuring 15 multiple-choice questions related to Python programming and Raspberry Pi. Each question includes a statement, options, the correct answer, and a detailed solution. The assignment assesses knowledge on topics such as Python syntax, library usage, file handling, and Raspberry Pi configuration.

Uploaded by

23uea028
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

NPTEL Online Certification Courses

Indian Institute of Technology Kharagpur

Introduction to
Internet of Things
Assignment-Week 6
TYPE OF QUESTION:MCQ/MSQ

Number of questions:15 Total marks: 15 X 1= 15

QUESTION 1:

State True or False.

Statement: “Python is popular for embedded application development as it is a very


lightweight programming language.”

a. True

b. False

Correct Answer: a. True

Detailed Solution: Python is popular for embedded application development as it is a very


lightweight programming language.

(Please refer to lecture INTRODUCTION TO PYTHON PROGRAMMING- I @ 1:22)


NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur

QUESTION 2:

State True or False.

Adafruit provides a library to work with DHT22 Sensor.

a. True
b. False

Correct Answer: a. True

Detailed Solution: Adafruit provides a library to work with DHT22 Sensor. (Please refer to
lecture Implementation of IoT with Raspberry Pi- II @ 4:41)

QUESTION 3:

Consider the following piece of Python code. What is the output?


x = [4, 5, 6]
y = [str(x[0] + 1), str(len(x) * 2) + '&Code']
z = y[1].split('&')
print(z[1])

a) 5
b) 12
c) Code
d) &Code

Correct Answer: c. Code

Detailed Solution:
1. x = [4, 5, 6]: A list with three elements.
2. y = [str(x[0] + 1), str(len(x) * 2) + '&Code']:
o x[0] is 4, so x[0] + 1 is 5, and str(x[0] + 1) becomes "5".
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur

o len(x) is 3, so len(x) * 2 is 6, and str(len(x) * 2) + '&Code' becomes "6&Code".


o Therefore, y = ["5", "6&Code"].
3. z = y[1].split('&'):
o y[1] is "6&Code".
o Splitting "6&Code" by '&' gives ['6', 'Code'].
4. z[1] is 'Code'.
Thus, the print(z[1]) statement outputs Code.

QUESTION 4:

State True or False.

Statement: “To indicate different blocks of code, Python follows rigid indentation.”

a. True
b. False

Correct Answer: a. True

Detailed Solution: To indicate different blocks of code, Python follows rigid indentation.

(Please refer to lecture INTRODUCTION TO PYTHON PROGRAMMING- I @ 7::29).

QUESTION 5:

What is the output of the following line of code in Python?


NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur

>>> print “Hi, Welcome to python!”

a. Hi, Welcome to python!


b. “Hi, Welcome to python!”
c. Hi, Welcome to python
d. None of these

Correct Answer: a. Hi, Welcome to python!

Detailed Solution: The output of the following line of code in Python -

>>> print “Hi, Welcome to python!”

Output: Hi, Welcome to python!

(Please refer to lecture INTRODUCTION TO PYTHON PROGRAMMING- II @ 07:31)

QUESTION 6:

During remote server access by a Raspberry Pi, where the Raspberry Pi acts as a client,
the client needs the following?

a. Only IP address of server

b. Only port number

c. Both server IP address and port number

d. Client’s IP address

Correct Answer: c. Both server IP address and port number

Detailed Solution: A client can communicate with a server only if both IP address and
port numbers are known. (Please refer Lecture 31@14:13)
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur

QUESTION 7:

State whether the following command to install the PIL library is correct or not.

sudo pip install pillow

a. Correct
b. Incorrect

Correct Answer: a. Correct

Detailed Solution: The command to install the PIL library is sudo pip install pillow.

(Please refer to lecture INTRODUCTION TO PYTHON PROGRAMMING- II @ 17:40 )

QUESTION 8:

What is the purpose of the "w" mode in the open() function in Python?

A) To read a file
B) To write data to a file, overwriting existing content
C) To append data to a file
D) To open a file in read and write mode

Correct Answer: B) To write data to a file, overwriting existing content

Detailed Solution: “w” mode is used to write data to a file, overwriting existing content

(Please refer to lecture INTRODUCTION TO PYTHON PROGRAMMING- II @05:05).


NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur

QUESTION 9:

What will be the output of the given Python program when reading from the file?

with open("PythonProgram.txt", "w") as file:


file.write("Writing data")
with open("PythonProgram.txt", "r") as file:
f = file.read() print('Reading from the file\n') print(f)

A) Writing data
B) Reading from the file
Writing data
C) Error: File not found
D) None of the above

Correct Answer: B. Reading from the file

Writing data

Detailed Solution: Reading from the file

Writing data

(Please refer to lecture INTRODUCTION TO PYTHON PROGRAMMING-II @05:05).

QUESTION 10:

Can we configure Raspberry Pi as a File Server?


NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur

a. Yes
b. No

Correct Answer: a. Yes

Detailed Solution: We can configure Raspberry Pi as a File Server.

See lecture INTRODUCTION TO RASPBERRY PI-I @ 02:46

QUESTION 11:

Which command is used to configure the Raspberry Pi for the camera module?

A) sudo camera-config
B) sudo raspi-config
C) sudo enable-camera
D) sudo pi-setup

Correct Answer: B) sudo raspi-config

Detailed Solution: sudo raspi-config is used to configure the Raspberry Pi for the
camera module

See lecture INTRODUCTION TO RASPBERRY PI-II @ 18:44

QUESTION 12:

What is the final step after enabling the camera in the Raspberry Pi configuration?
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur

A) Restart the camera service


B) Run a camera test command
C) Reboot the Raspberry Pi
D) Reinstall the Raspberry Pi OS

Correct Answer: C) Reboot the Raspberry Pi

Detailed Solution: after enabling the camera in the Raspberry Pi configuration, reboot.
See lecture IMPLEMENTATION OF IOT WITH RASPBERRY PI-II @ 18:44

QUESTION 13:

Which command Exits the nano editor?

a. Ctrl + X

b. Ctrl + O

c. Ctrl + K

d. None of these

Correct Answer: a. Ctrl + X

Detailed Solution: Ctrl + O exits the nano editor.

See lecture IMPLEMENTATION OF IOT WITH RASPBERRY PI-II @ 10:20

QUESTION 14:

In a temperature-controlled fan system using a relay, when should the fan turn on?
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur

A) When the relay is manually triggered


B) When the surrounding temperature is lower than a predefined threshold
C) When the surrounding temperature exceeds a predefined threshold
D) When the battery voltage drops below a certain level

Correct Answer: C) When the surrounding temperature exceeds a predefined threshold

Detailed Solution: In a temperature-controlled fan system using a relay, the fand should turn on
when the surrounding temperature exceeds a predefined threshold.

(Please refer to lecture INTRODUCTION TO PYTHON PROGRAMMING- II @ 11:18)

QUESTION 15:

What does the following line of code do?

raspistillcapture -o image.jpg

a. Captures video feed


b. Captures still image
c. Both (a) and (b)
d. None of these

Correct Answer: d. None of these

Detailed Solution: Command is wrong.

(Please refer to lecture INTRODUCTION TO RASPBERYY PI-II @ 19:29)

************END***********

You might also like