Docsity

Python Programs for Computer Science Students, Exams of Computer science

Toggle sidebar
bg1
TRINITY MATRIC HR SEC SCHOOL , RAMANATHAPURAM , COIMBATORE โ€“ 641045.
2020-2021
STD : XII A LESSON : 6(BOOK EXERCISE)
SUB : COMPUTER SCIENCE TOPIC : PYTHON Programs
HANDS ON EXPERIENCE ( P.NO : 86 )
1.Write a Program in Python to check whether the given character is vowel or not.
Program :
ch=input("Enter a Character : ")
if ch in ('a','A','e','E','i','I','o','O','u','U'):
print(ch,' is a Vowel')
else:
print(ch,' is NOT a Vowel')
Output : 1
Enter a Character : E
E is a Vowel
Output : 2
Enter a Character : t
t is NOT a Vowel
2.Write a Program in Python to Find the Smallest of 3 Numbers using if-elif-else
Program:
a=int(input("Enter Number 1:"))
b=int(input("Enter Number 2:"))
c=int(input("Enter Number 3:"))
if a<b and a<c:
print("A is Smallest")
elif<a and b<c:
print("B is Smallest")
else:
print("C is Smallest")
Output :
Enter Number 1:34
Enter Number 2:78
Enter Number 3:12
C is Smallest
pf3
pf4
pf5

Partial preview of the text

Download Python Programs for Computer Science Students and more Exams Computer science in PDF only on Docsity!

TRINITY MATRIC HR SEC SCHOOL , RAMANATHAPURAM , COIMBATORE โ€“ 641045. 2020- STD : XII A LESSON : 6(BOOK EXERCISE) SUB : COMPUTER SCIENCE TOPIC : PYTHON Programs HANDS ON EXPERIENCE ( P.NO : 86 ) 1.Write a Program in Python to check whether the given character is vowel or not. Program : ch=input("Enter a Character : ") if ch in ('a','A','e','E','i','I','o','O','u','U'): print(ch,' is a Vowel') else: print(ch,' is NOT a Vowel') Output : 1 Enter a Character : E E is a Vowel Output : 2 Enter a Character : t t is NOT a Vowel 2.Write a Program in Python to Find the Smallest of 3 Numbers using if-elif-else Program: a=int(input("Enter Number 1:")) b=int(input("Enter Number 2:")) c=int(input("Enter Number 3:")) if a<b and a<c: print("A is Smallest") elif<a and b<c: print("B is Smallest") else: print("C is Smallest") Output : Enter Number 1: Enter Number 2: Enter Number 3: C is Smallest

3.Write a Program in Python to check Whether the given Number is Positive 0r Negative or Zero Program: x=int(input("Enter the Number:")) if x>0: print(x," is a Positive Number") elif x<0: print(x," is a Negative Number") else: print(x," is Zero") Output : 1 Enter the Number: 6 is a Positive Number Output : 2 Enter the Number:- -4 is a Negative Number Output : 3 Enter the Number: 0 is Zero 4.Write a Program in Python to Display the Fibanacci Series 0 1 1 2 3 5 8 โ€ฆโ€ฆ(upto N Terms) Program: a,b,c=0,1, n=int(input("Enter the No of Terms ")) print(a,end='\t') print(b,end='\t') for i in range(3,n+1): c=a+b print(c,end='\t') a=b b=c Output : Enter the No of Terms 8 0 1 1 2 3 5 8 13 5.Write a Program in Python to Display the Sum of N Natural Numbers Program: s= n=int(input("Enter the No of Terms ")) for i in range(1,n+1): s=s+i print("Sum=",s)

8.Write a Program in Python to check Whether the given Year is Leap year or not Program: y=int(input("Enter the Year:")) if y%400==0 or y%4==0 or y%100==0: print("The Given Year is Leap Year") else: print("The Given Year is NOT a Leap Year") Output : Enter the Year: The Given Year is NOT a Leap Year Output : Enter the Year: The Given Year is Leap Year PART โ€“ III (Programs) 1.Write a Program in Python to Display A A B A B C A B C D A B C D E Program : for i in range(65,70): for j in range(65,i+1): print(chr(j),end='') print(end='\n') i+= Output : A AB ABC ABCD ABCDE

3.Write a Program in Python to Find the Largest of 3 Numbers using if-elif-else Program: a=int(input("Enter Number 1:")) b=int(input("Enter Number 2:")) c=int(input("Enter Number 3:")) if a>b and a>c: print("A is Biggest") elif b>a and b>c: print("B is Biggest") else: print("C is Biggest") Output : Enter Number 1: Enter Number 2: Enter Number 3: C is Biggest PART โ€“ IV (Programs) 4.Write a Program in Python to display all the 3 digits odd numbers Program: for i in range(101,1000,2): print(i,end='\t') Output : 101 103 105 107 109 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 141 143 145 147 149 151 153 155 157 159 161 163 165 167 169 171 173 175 177 179 181 183 185 187 189 191 193 195 197 199 201 203 205 207 209 211 213 215 217 219 221 223 225 227 229 231 233 235 237 239 241 243 245 247 249 251 253 255 257 259 261 263 265 267 269 271 273 275 277 279 281 283 285 287 289 291 293 295 297 299 301 303 305 307 309 311 313 315 317 319 321 323 325 327 329 331 333 335 337 339 341 343 345 347 349 351 353 355 357 359 361 363 365 367 369 371 373 375 377 379 381 383 385 387 389 391 393 395 397 399 401 403 405 407 409 411 413 415 417 419 421 423 425 427 429 431 433 435 437 439 441 443 445 447 449 451 453 455 457 459 461 463 465 467 469 471 473 475 477 479 481 483 485 487 489 491 493 495 497 499 501 503 505 507 509 511 513 515 517 519 521 523 525 527 529 531 533 535 537 539 541 543 545 547 549 551 553 555 557