0% found this document useful (0 votes)
84 views8 pages

Cs Solutions

This document contains solutions to coding questions and explanations of concepts related to computer science and programming. It is divided into 5 sections covering topics like data structures, algorithms, functions, strings and more. Questions include writing functions to check for palindromes, calculate volume of boxes, and determine if brackets in a string are balanced. Solutions demonstrate various Python programming concepts like lists, tuples, and manipulating strings.
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)
84 views8 pages

Cs Solutions

This document contains solutions to coding questions and explanations of concepts related to computer science and programming. It is divided into 5 sections covering topics like data structures, algorithms, functions, strings and more. Questions include writing functions to check for palindromes, calculate volume of boxes, and determine if brackets in a string are balanced. Solutions demonstrate various Python programming concepts like lists, tuples, and manipulating strings.
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

Cs solutions

Section A

1. True
2. D
3. A
4. A
5. A
6. B
7. B
8. -
9. A
10.b
11.A
12.C
13.A
14.A
15.A
16.B
17.C - (A) is true but (R) is false
18.A- Both (A) and (R) are true and R is the correct explanation of A

Section B
19.
20.
21.
22.

LIST TUPLE

1 Lists are mutable Tuples are immutable

2 The implication of iterations is The implication of iterations is


Time-consuming comparatively Faster

3 The list is better for performing Tuple data type is appropriate


operations, such as insertion and for accessing the elements
deletion.

4 Lists consume more memory Tuple consumes less memory


as compared to the list
23.a
i) SMTP: Simple Mail Transfer Protocol (ii) PPP: Point to Point Protocol

ii) Star topology is a network topology in which each network component is


physically connected to a central node such as a router, hub or switch.

In a star topology, the central hub acts like a server and the connecting nodes act like
clients.

[Link] the output of the Python code given below:


tuple1 = (11, 22, 33, 44, 55 ,66)
list1 =list(tuple1)
new_list = [] for i in list1: if i%2==0: new_list.append(i)
new_tuple = tuple(new_list)
print(new_tuple)
Ans: (22,44,66)
[Link] is a linear data structure which follows a particular order in which the
operations are performed. The order may be LIFO(Last In First Out) or FILO(First In
Last Out).Push is a function in stack definition which is used to insert data at the
stack's top. Pop is a function in the stack definition which is used to remove data from
the stack's top.
Section D

[Link] vol( l = 1, w = 1 , h = 1 ) :
return l * w * h

length = int(input("Enter the length : "))


width = int(input("Enter the width : "))
height = int(input("Enter the height : "))

print("volume of box = ", vol( length , width , height ))

Output :-

Enter the length : 5


Enter the width : 2
Enter the height : 3
volume of box =  30
>>>

Enter the length : 84


Enter the width : 69
Enter the height : 75
volume of box =  434700
>>> 

Enter the length : 1


Enter the width : 1
Enter the height : 1
volume of box =  1

32.-

33.

F=pen('[Link]',
'r')
c_up=0
ch = [Link](1)
while ch:
ch=[Link](1)
if [Link]():
c_up+=1
print("Number
of Uppercase
alphabets
is/are:",c_up)

Output :-

Number of upper case alphabet  :  8

Section E

34.# function to check string is

# palindrome or not

def isPalindrome(str):

# Run loop from 0 to len/2

for i in range(0, int(len(str)/2)):

if str[i] != str[len(str)-i-1]:

return False
return True

# main function

s = "malayalam"

ans = isPalindrome(s)

if (ans):

print("Yes")

else:

print("No")

Output: 
Yes
Time complexity: O(n)
Auxiliary Space: O(1)
35
[Link] isbalanced(s):

while(len(s)!=0):

s=[Link]('()','')

s=[Link]('[]','')

s=[Link]('{}','')

if(len(s)==0):

return True

else:

return False

s=input("Enter a string of brackets:")print("Given string is


balanced:",isbalanced(s))

Enter a string of brackets: ({{}}){}[]


Given string is balanced : True

You might also like