Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
4 views

12CS_ProgramBasedTest1

The document contains a series of Python programming exercises and their expected outputs, covering various concepts such as arithmetic operations, loops, conditionals, functions, and built-in functions. Each snippet is designed to test the understanding of Python syntax and functionality. The document is intended for students learning computer science.

Uploaded by

Mohamed Janees
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

12CS_ProgramBasedTest1

The document contains a series of Python programming exercises and their expected outputs, covering various concepts such as arithmetic operations, loops, conditionals, functions, and built-in functions. Each snippet is designed to test the understanding of Python syntax and functionality. The document is intended for students learning computer science.

Uploaded by

Mohamed Janees
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

12 – COMPUTER SCIENCE

LESSONS – 5, 6 & 7

என்றும் மாணவர்கள் நலனில்

WRITE THE OUTPUT OF THE FOLLOWING SNIPPETS. / பின்வரும் குறிமுறைகளின் வெளியீட்டை எழுதுக.

1) >>> 2  5

2) >>>100//3

3) Match the following


a) 0b1010 - i) Octal Literals
b) 100 - ii) Hexadecimal Literal
c) 0o310 - iii) Binary Literal
d) 0x12c - iv) Decimal Literal

4) >>> print("\"Python\"")

5) a = -5
x="even" if a%2==0 else "odd"
print (a, " is ",x)

6) i=10
while (i<=15):
print (i,end='\t')
i=i+1

7) i=10
while (i<=15):
i=i+1
print (i,end='\t')

8) for x in (1,2,3,4,5):
print("Tech Easy")

9) for x in (1,2,3,4,5):
print(x, end=' ')

..1.. A. PRABHAKAR - 9442979144


10) n = 10
sum = 0
for counter in range(1, n+1):
sum = sum + counter

print("Sum of 1 until %d: %d" % (n, sum))

11) for x in range(5):


if x==2:
continue
print(x, end='')

12) for i in range(1,10,2):


print(i, end='')

13) i=1
while (i<=6):
for j in range (1,i):
print (j,end='\t')
print (end='\n')
i += 1

14) i=1
while (i<=6):
for j in range (1,i):
print (‘$’,end='\t')
print (end='\n')
i += 1

15) i=1
while True:
if i%5 == 0:
break
print(i,end=' ')
i +=1

16) for cs in “tech easy”:


if cs=='e':
pass
print(cs, end='')

..2.. A. PRABHAKAR - 9442979144


17) for sub in “computer science”:
if sub=="e":
continue
print(sub, end='')
18) def hello():
print ("hello - Python")
return
print (hello())

19) def printinfo(name, salary = 3500):


print ("Name: ", name)
print ("Salary: ", salary)
return
printinfo("Mani")

20) def printnos (*nos):


for n in nos:
print(n)
return
printnos (1,2,10,30,7)

21) c = 1
def add():
c = c + 2
print(c)
add()

22) c = 1
def add():
global c
c = c + 2
print (c)
add()

23) x = 0
def add():
global x
x = x + 5
print ("Inside add() function x value is :", x)
add()
print ("In main x value is :", x)

..3.. A. PRABHAKAR - 9442979144


24) print ('A = ',ord(‘A’))
print(chr(97))
print (type(15.2))

25) MyList = [-21,-76,-98,-23]


print ('Maximum of MyList :', max(MyList))

26) n1=17.89
print (round (n1))
print (round (n1,0))
print (round (n1,1))
print (round (n1,2))

27) x=26.7
print(math.floor(x))
print(math.ceil(x))

28) print(format(66, 'c'))


print(format(10, 'x'))
print(format(10, 'X'))
print(format(0b110, 'd'))
print(format(0xa, 'd'))

29) print(pow(3,2))
print(pow(-3,2))
print(pow(-3,3))

30) print(abs(-8))
print(abs(8))

..4.. A. PRABHAKAR - 9442979144

You might also like