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

Maha - Python One Mark QP

This document contains 15 multiple choice questions about Python programming, file handling in Python, HTML, CSS, web servers, protocols, XML and XPath. The questions cover topics like how Python executes code, defining functions, valid identifier names, classes and objects, opening and reading/writing files, advantages of CSS, relative URLs, commands used in different protocols, differences between XML and HTML, and using XPath to navigate XML documents. Each question is followed by 4 answer options and the correct answer.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views

Maha - Python One Mark QP

This document contains 15 multiple choice questions about Python programming, file handling in Python, HTML, CSS, web servers, protocols, XML and XPath. The questions cover topics like how Python executes code, defining functions, valid identifier names, classes and objects, opening and reading/writing files, advantages of CSS, relative URLs, commands used in different protocols, differences between XML and HTML, and using XPath to navigate XML documents. Each question is followed by 4 answer options and the correct answer.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Mangala Aishwarya R,18085uel09

18BELE22 - Python programming quiz questions with answers for unit 3,4&5.

1) Python executes source code using

A. Interpreter

B. Translator

C. Compiler

D. All the above

Answer: Option A

2)What is the correct way to create a function in Python?

A. function myfunction():

B. create myFunction():

C. def myFunction():

D. Fn functions

Answer : Option C

3) Which one of the following is a valid identifier declaration in Python?

A.str = “demo666”

B.str = “666”

C.str = “demo demo2”

D.str = “$$$666”

Answer : A

4)Which of the following represents a distinctly identifiable entity in the real world?

A.. A class

B. An object

C. A method

D. A data field

Answer. B

5)Which of the following is required to create a new instance of the class?

A. A constructor
B. A class

C. A value-returning method

D. A None method

Answer. A

6) . To open a file c:\scores.txt for reading, we use _____________

a) infile = open(“c:\scores.txt”, “r”)

b) infile = open(“c:\\scores.txt”, “r”)

c) infile = open(file = “c:\scores.txt”, “r”)

d) infile = open(file = “c:\\scores.txt”, “r”)

Answer: b

7)To read two characters from a file object infile, we use ____________

a) infile.read(2)

b) infile.read()

c) infile.readline()

d) infile.readlines

Answer: a

8) To read the entire remaining contents of the file as a string from a file object infile, we use
____________

a) infile.read(2)

b) infile.read()

c) infile.readline()

d)rd()

Answer :c

9) What will be the output of the following Python code?

F = None

For I in range (5):

With open(“data.txt”, “w”) as f:

If I > 2:
Break

Print(f.closed)

a) True

b) False

c) None

d) Error

Answer: a

10)HTML(Hypertext Markup Language) has language elements which permit certain actions other than
describing the structure of the web document. Which one of the following actions is NOT supported by
pure HTML (without any server or client side scripting)pages?

A.Embed web objects from different sites into the same page

B.Refresh the page automatically after a specified interval

C.Automatically redirect to another page upon download

D.rval client time as part of the page

Answer.d

11) Which of the following is an advantage of putting presentation information in a separate CSS file
rather than in HTML itself?A.The content becomes easy to manage

B.Becomes easy to make site for different devices like mobile by making separate CSS files

C.CSS Files are generally cached and therefore decrease server load and network traffic.

D.All of the above

Answer.d

12) In a web server, ten WebPages are stored with the URLs of the form
http://www.yourname.com/var.html; where, var is a different number from 1 to 10 for each Webpage.
Suppose, the client stores the Webpage with var = 1 (say W1) in local machine, edits and then tests. Rest
of the WebPages remains on the web server. W1 contains several relative URLs of the form “var.html”
referring to the other WebPages. Which one of the following statements needs to be added in W1, so
that all the relative URLs in W1 refer to the appropriate WebPages on the web server?

A.<a.href: “http://www.yourname.com/”, href: “...var.html”>

B.<base href: “http://www.yourname.com/”>

C.<a.href: “http://www.yourname.com/”>

D.http://www.yourname.com/”, range: “...var.html”

Answer. b
13) Consider the three commands : PROMPT, HEAD and RCPT. Which of the following options indicate a
correct association of these commands with protocols where these are used?

HTTP, SMTP, FTP

FTP, HTTP, SMTP

HTTP, FTP, SMTP

SMTP, HTTP, FT

Answer.b

14) Which of the following is TRUE only of XML but NOT HTML?

A.It is derived from SGML

B.It describes content and layout

C.It allows user defined tags

D.It is restricted only to be used with web browsers

Answer.c

15)XPath is used to navigate through elements and attributes in

A.XSL document

B.XML document

C.XHTML document

D.XQuery document

Answer.b

You might also like