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

Simplified Computer Science Practical Template 1

Uploaded by

q1rp5q4faz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

Simplified Computer Science Practical Template 1

Uploaded by

q1rp5q4faz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Practical

Exercise 1

Program
Question Number 01
A = int(input("Enter the first number"))
B = int(input("Enter the second number" )) WAP to find the greatest number
C = int(input("Enter the third number")) among the three inputed number
if (A>B):
if (A>C):
print(A,"is the greatest number ")
else:
print(C,"is the greatest number ") Output
else:
if(B>C):
print(B,"is the greatest number")
else:
print(C,"is the greatest number ")
Practical Exercise 2

Program Question Number 02


WAP that reads two numbers and an
A = float(input("Enter the first number ")) arithmetic operator and displays the
B = float(input("Enter the second number result
"))
C = input("Enter the operator ")
if(C == '+'):
print(A+B)
elif(C == '-'):
print(A-B)
elif(C == '*'): Output
print(A*B)
elif(C == '/'):
print(A/B)
else:
print("invalid option ")
Practical Exercise 4 Question 03

WAP to accept a character from user and


Program
display whether it is a vowel or consonant:
Character = input("Enter the character ")
if(Character == 'a' or Character == 'A' ):
print(Character,"is a vowel") elif(Character
== 'e' or Character == 'E'):
print(Character,"is a vowel") elif(Character
Output
== 'i' or Character == 'I'):
print(Character,"is a vowel") elif(Character
== 'o' or Character == 'O'):
print(Character,"is a vowel") elif(Character
== 'u' or Character == 'U'):
print(Character,"is a vowel") else:
print(Character,"is a consonant")
Practical Exercise 4

QUESTION 04
WAP to check if the inputed number is
positive or negativie:

PROGRAM
num = float(input("Enter the number"))
if(num < 0):
print(num,"is negative")
elif(num > 0): Output
print(num,'is positive')
else:
print(num,'is zero')
Practical Exercise 5

QUESTION 05
WAP to print all the even numbers
PROGRAM between 10 to 20

for i in range(10, 21):


if i % 2 == 0:
print(i)

Output
Practical Exercise 6

PROGRAM
Program Name
num = int(input("Enter a number: "))
if num < 0: Mention the specific name or title of the
print("Error: Factorial is not defined for program.
negative numbers.")
else:
fact = 1
for i in range(1, num + 1):
fact *= i
print("Factorial of", num, "is:", fact)

Output
Practical Exercise 07

PROGRAM QUESTION 07
WAP that displays all the prime numbers
below 30
for num in range(2, 30):
if num > 1:
for i in range(2, num):
if (num % i) == 0:
break
else:
print(num)
Output
Practical Exercise 8

PROGRAM QUESTION 08
WAP to accept a number and print its
num = int(input("Enter a number: ")) reverse order
reverse_num = 0

while num != 0:
remainder = num % 10
reverse_num = (reverse_num * 10) +
remainder
num = num // 10
Output
print("Reverse number:", reverse_num)
Practical Exercise 9

QUESTION
PROGRAM
WAP to print fibonacci series upto a
given limit:
i = int(input('enter the limit '))
x =0
y=1
z=1
print("fibonacci series\n")
print(x,y,end = ' ')
while(z<=i):
print(z,end = ' ') Output
x =y
y=z
z = x+y
Practical Exercise 10

QUESTION 10
PROGRAM
num = int(input("enter the number")) WAP to check if the inputed number
for i in range(2,num//2+1): is prime or not
if(num%i==0):
print(num,"is not a prime number")
break
else:
print(num,"is a prime number ")

Output
Practical Exercise 11
QUESTION 11
PROGRAM
WAP to check if the given number is
orig = int(input("enter the number ")) palindrome or not
num = orig
rev = 0
while (num > 0 ):
digit = num % 10
rev = rev * 10 + digit
num = int(num/10) Output
if (orig == rev):
print(orig,"is palindrome")
else:
print(orig,"is not palidrome")
Practical Exercise 12

PROGRAM QUESTION
WAP to convert decimal to binary

n = int(input("enter the number "))


a=0
m=0
c=1
while (n > 0):
a = n%2 Output
m = m+(a*c)
c = (c*10)
n = int(n/2)
print(m)
Practical Exercise 13

QUESTION
PROGRAM
WAP to check if the given number is
num = int(input("Enter a three digit
armstrong or not
number "))
f = num
sum =0
while(f > 0):
a = f%10
f = int(f/10)
sum = sum + (a**3)
if (sum == num):
print(num,"is an armstrong number") Output
else:
print(num,"is not a armstrong number")

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy