Question
Krishna is confused in Python code given below. Please help him to answer the following questions.

(a) Which line in the above code check for capital letter?

(b) Which line in the above code read the file “story. txt”?

(c) Which line in the above code does not affect the execution of program?

(d) Which line is the above code coverts capital letter to small letter?

(e) Which line is the above code opens the file in write mode?

(f) Which line is the above code saves the data?

(g) Which line(s) is/are the part of selection statement.

(h) Which line(s) is/are used to close story1.txt?

Answer

(a) Line 6(e) Line 2
(b) Line 4 (f) Line 13
(c) Line 10(g) Line 6, Line 8 and Line 11
(d) Line 7(h) Line 15

Need a full question paper?

Generate a complete, print-ready paper with questions like this in minutes — across 16+ boards, with answer keys.

Start Generating Free

Similar questions

Consider the following tables GAMES and PLAYER. Write SQL commands for the statements (a) to (d) and give outputs for SQL queries (e1) to (e4)

Relation: GAMES

GCode Game Name Number Prize Money Schedule Date
101 Carom Board 2 5000 3-Jan-2004
102 Badminton 2 12000 12-Dec-2003
103 Table Tennis 4 8000 14-Feb-2004
105 Chess 2 9000 01-Jan-2004
108 Lawn
Tennis
4 25000 19-Mar-2004

Relation: PLAYER

PCode Name Gcode
1 Nabi Ahmad 101
2 Ravi Sahai 108
3 Jatin 101
4 Nazneen 103

(a) To display the name of all Games with their Gcodes

(b) To display details of those games which are having PrizeMoney more than 7000.

(c) To display the content of the GAMES table in ascending order of ScheduleDate.

(d) To display sum of PrizeMoney for each of the Number of participation groupings (as shown in column Number)

(e1) Select COUNT(DISTINCT Number) FROM GAMES;

(e2) Select MAX(ScheduleDate),MIN(ScheduleDate) FROM GAMES;

(e3) Select SUM(PrizeMoney) FROM GAMES;

(e4) Select DISTINCT Gcode FROM PLAYER;

Choose the correct option.

(a) What is String data-type in Python?

(i)It is written in double quotes only.

(ii)Its value can be changed.

(iii)It is enclosed in square brackets.

(iv)It is immutable data-type.

(b) Ms. Ragini is confused on the way to compare the strings. Help her in choosing the correct statement.

(i)equal() (ii)equals() (iii) == (iv)compare()

(c) Tejas is confused in the output of the following code. Help him to choose the correct option.

age = 12

txt = "My name is Tejas, I am " , age

print(txt)

(i)('My name is Tejas, I am ', 12)

(ii)My name is Tejas, and I am 12

(iii)(My name is Tejas, I am , 12)

(iv)[My name is Tejas, I am , 12]

(d) Help mini to choose the correct output of the following Python code.

rollno = 3

name = "Mini"

Average = 88.76

Txt = "My name is {1}, having roll no {0} and scored {2} percent."

print(Txt.format(rollno, name, Average))

(i)My name is ‘Mini’, having roll no 3 and scored 88.76 percent.

(ii)My name is Mini, having roll no 3 and scored 88.76 percent.

(iii)‘My name is Mini, having roll no 3 and scored 88.76 percent.’

(iv)(My name is Mini, having roll no 3 and scored 88.76 percent.)

(e) Help Gurnika to choose the correct option for the following Python code.

b = "Hello, World!"

print(b[-5:2])

(i)Hello, World! (ii)orl (iii) Error (iv) No Output

Mr. Iqbal is a programmer, who has recently joined the company and given a task to write a python code to perform the following binary file operations with the help of two user defined functions/modules:
(a)

Answer the following questions.

Bills

Bill No Date I_Code qty

1

1

2

2

2

3

4

4

5

5

5

2010-04-01

2010-04-01

2010-04-01

2010-04-01

2010-04-01

2010-04-02

2010-04-02

2010-04-02

2010-04-03

2010-04-03

2010-04-03

1002

3001

1001

1002

2003

2002

2002

2003

2003

3001

3002

2

1

3

1

2

1

4

2

2

1

3

Items

I_Code Name Category

1001

1002

1003

2001

2002

2003

3001

3002

2010-04-01

2010-04-01

2010-04-01

2010-04-01

2010-04-01

2010-04-02

2010-04-02

2010-04-02

1002

3001

1001

1002

2003

2002

2002

2003

(a) Based on these tables write SQL statements for the following queries:

(i) Display the average rate of a South Indian item.

(ii) Display the number of items in each category.

(iii) Display the total quantity sold for each item.

(iv) Display total quantity of each item sold but don't display this data for the items whose total quantity sold is less than 3.

(v) Display the details of bill records along with Name of each corresponding item.

(v) Display the details of the bill records for which the item is 'Dosa'.

(vi) Display the details of the bill records for which the item is 'Dosa'.

(vii) Display the bill records for each Italian item sold.

(viii) Display the total value of items sold for each bill.

(b) Identify the Foreign Keys (if any) of these tables. Justify your answer.

(c) Answer with justification (Think independently. More than one answers may be correct. It all depends on your logical thinking):

(i) Is it easy to remember the Category of item with a given item code? Do you find any kind of pattern in the items code? What could be the item code of another South Indian item?

(ii) What can be the possible uses of Bills table? Can it be used for some analysis purpose?

(iii) Do you find any columns in these tables which can be NULL? Is there any column which must not be NULL?

Read the following code carefully which is implementing the concept of STACK:

Now answer the following based on the code given:

(a) How are the above two functions interrelated?

(i) The function isEmpty(STACK) will be called when pop(STACK) is called

(ii) The function pop(STACK) will be called when is Empty(STACK) is called

(iii) Both functions are implementing recursion

(iv) These functions are not related to each other.

(b) What is the difference in between STACK.pop() and pop(STACK)

(i) Both are pre-defined functions

(ii) Both are user-defined functions

(iii) STACK.pop() is pre defined and pop(STACK) is user defined

(iv) STACK.pop() is user defined and pop(STACK) is pre defined

(c) What is the return type of the function defisEmpty (STACK)

(i) None (ii) void

(iii) int (iv) Boolean

(d) What will the pop(STACK) function return if the stack already consist of [‘A’,’B’] at the position 0 and 1 respectively

(i) A (ii) B (iii) Both A and B (iv) None

(e) if len(STACK) == 0: What is the purpose of this line in the above code:

(i) It checks if the stack is already full

(ii) It checks if the stack can add more value in it or not

(iii) It checks if the stack is already empty

(iv) It checks if the stack exist or not

Consider the following DEPT and WORKER tables. Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii): [Delhi 2015]

Table: DEPT

DCODE DEPARTMENT CITY
D01 MEDIA DELHI
D02 MARKETING DELHI
D03 INFRASTRUCTURE MUMBAI
D05 FINANCE KOLKATA
D04 HUMAN RESOURCE MUMBAI

Table: WORKER

WNO NAME DOJ DOB GENDER DCODE
1001 George K 2013-09-02 1991-09-01 MALE D01
1002 Ryma Sen 2012-12-11 1990-12-15 FEMALE D03
1003 Mohitesh 2013-02-03 1987-09-04 MALE D05
1007 Anil Jha 2014-01-17 1984-10-19 MALE D04
1004 Manila Sahai 2012-12-09 1986-11-14 FEMALE D01
1005 R SAHAY 2013-11-18 1987-03-31 MALE D02
1006 Jaya Priya 2014-06-09 1985-06-23 FEMALE D05

Note: DOJ refers to date of joining and DOB refers to date of Birth of workers.

(i) To display Wno, Name, Gender from the table WORKER in descending order of Wno.

(ii) To display the Name of all the FEMALE workers from the table WORKER.

(iii) To display the Wno and Name of those workers from the table WORKER who are born between ‘1987-01-01’ and ‘1991-12-01’.

(iv) To count and display MALE workers who have joined after ‘1986-01-01’.

(v) SELECT COUNT(*), DCODE FROM WORKER GROUP BY DCODE HAVING COUNT(*)>1;

(vi) SELECT DISTINCT DEPARTMENT FROM DEPT;

(vii) SELECT NAME, DEPARTMENT, CITY FROM WORKER W,DEPT D WHERE W.DCODE=D.DCODE AND WNO<1003;

(viii) SELECT MAX(DOJ), MIN(DOB) FROM WORKER;

Xcelencia Edu Services Ltd. is an educational organization. It is planning to set up its India campus at Hyderabad with its head office at Delhi. The Hyderabad campus has four main buildings -ADMIN, SCIENCE, BUSINESS and MEDIA.

You as a network expert have to suggest the best network related solutions for their problems raised in (a) to (d), keeping in mind the distances between the buildings and other given parameters.

Shortest Distances between various buildings:

ADMIN to SCIENCE65 M
ADMIN to BUSINESS100 m
ADMIN to ARTS60 M
SCIENCE to BUSINESS75 M
SCIENCE to ARTS60 M
BUSINESS to ARTS50 M
DELHI Head Office to HYDERABAD Campus1600 KM

Number of Computers installed at various building are as follows:

ADMIN100
SCIENCE85
BUSINESS40
ARTS12
DELHI Head Office20

(a) Suggest the most appropriate location of the server inside the HYDERABAD campus (out of the 4 buildings), to get the best connectivity for maximum no. of computers. Justify your answer.

(b) Suggest and draw the cable layout to efficiently connect various buildings ‘within the HYDERABAD campus for connecting the computers.

(c) Which hardware device will you suggest to be procured by the company to be installed to protect and control the internet uses within the campus?

(d) Which of the following will you suggest to establish the online face-to-face communication between the people in the Admin Office of HYDERABAD campus and DELHI Head Office? E-mail, Text Chat, Video Conferencing, Cable TV.

Explain how technology is making our society simpler and better?
Mr. Naveen is working as data analyst. He was facing some problem related to panda’s library, help him in answering the given questions:
(a) He wants to display only 2 columns i.e. PNAME and Company, choose the right comman(d)

(b) He wants the given output, choose the right command:

(c) What will be the output of the given command? print(df.size)
(i) 20 (ii) 4
(iii) 24 (iv) 16
(d) Choose the command which will display the number of rows and columns of the above Dataframe
(i) print(dfshape)
(ii) print(dfshape()
(iii) print(dfrows,dfcolumns)
(iv) print(dfloc[],dfiloc[])
(e) What will be the output of the following command?
print(dfloc[2:4,’PNAME’])

Consider the following DataFrameDf1 and answer any four questions from (i) – (iv)

City Hospitals Schools
0 Delhi 189 7916
1 Mumbai 208 8508
2 Kolkata 149 7226
3 Chennai 157 7617

(a) Choose the right statement to get the given output:

(i) Df1.mean()

(ii) Df1.mean(axis=1)

(iii) Df1.average()

(iv) Df1.median()

(b) Write the command to get the given output:

City Hospitals Schools
3 Chennai 157 7617
0 Delhi 189 7916
2 Kolkata 149 7226
1 Mumbai 208 8508

(i) Df1.sort(by=‘City’)

(ii) Df1.sort_values(‘City’)

(iii) Df1.sort_values(by=‘City’)

(iv) Df1.sort_values(by==‘City’)

(c) Choose the right statement to get given output:

Hospitals Schools
count 4,000000 4,000000
mean 175.750000 7816.750000
std 27.584718 540.543785
min 149.000000 7226.000000
25% 155.000000 7519.250000
50% 173.000000 7766.500000
75% 193.000000 8064.000000
max 208.000000 8508.000000

(i) Df1.desc()

(ii) Df1.statistics()

(iii) Df1.desctibe()

(iv) Df1.showall()

(d) Chose the right function to fill in given statement to make the city as index value:

Df1._________________(‘City’,inplace=True)

(i) Df1.set_index(‘City’,inplace=True)

(ii) Df1.index('City',inplace=True)

(iii) Df1.new_index(‘City ‘,inplace=True)

(iv) Df1.reset_index(‘City’,inplace=True)

(e) Which Pandas command is used to rename the columns & index name of the above dataframe

(i) Df1.renamecolumns()

(ii) Df1.Rename()

(iii) Df1.rename()

(iv) Df1.indexrename()