0% found this document useful (0 votes)
46 views50 pages

Karthikeya - CS Journal

Here is a program to calculate BMI and print the status: print("Kailasapu Karthikeya") print("Question 7") print("CBSE 11A") print("--------------") weight = float(input("Enter your weight in kg: ")) height = float(input("Enter your height in meters: ")) bmi = weight / (height**2) print("Your BMI is:", bmi) if bmi < 18.5: print("You are underweight") elif bmi < 25: print("You have normal weight") elif bmi < 30: print("You are overweight") else:
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)
46 views50 pages

Karthikeya - CS Journal

Here is a program to calculate BMI and print the status: print("Kailasapu Karthikeya") print("Question 7") print("CBSE 11A") print("--------------") weight = float(input("Enter your weight in kg: ")) height = float(input("Enter your height in meters: ")) bmi = weight / (height**2) print("Your BMI is:", bmi) if bmi < 18.5: print("You are underweight") elif bmi < 25: print("You have normal weight") elif bmi < 30: print("You are overweight") else:
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/ 50

COMPUTER SCIENCE - 083

JOURNAL
Name of Candidate: Kailasapu Karthikeya
Roll No. of Candidate: 15
Class: XIA CBSE

Certificate

The Department of Information & Technology

Global Indian International School (GIIS).

SMART Campus, Punggol, Singapore

This is to certify that this practical file is a genuine work of

_______ ____________ Roll No. ______ undertaken as a part of

fulfilment of Computer Science practical syllabus for

A.I.S.S.C.E. 2022 – 2023 to be conducted by C.B.S.E. and has

been completed within stipulated time period under my

guidance and supervision.

1
Internal Examiner:- Signature:-

Internal Examiner Number:-

Date:

INDEX

No. Code Signature

Sequential Construct
WAP to read 3 numbers from the user and print the sum and average.
1.

Sequential Construct
WAP to read 2 numbers from user and print maximum number
2.

3. Selective/ Conditional Construct


WAP to read 3 numbers from user and print maximum number (chaining of
relational operator)
4. Selective/ Conditional Construct

2
WAP to read 3 numbers from the user and print the maximum number (nested

if structure).

5. Selective/ Conditional Construct


WAP to read 3 numbers from the user and print the maximum number
(combining conditions with logical operators).

6. Selective/ Conditional Construct


WAP to simulate a 4 function calculator. (nested if structure)
Reads 2 integers and an arithmetic operator and displays the result
[assuming values are valid].

7. Selective/ Conditional Construct


Write a program to calculate
BMI = (weight/height2)
of a person after in putting their weight in kgs and height in meters and then
print the status as
Underweight <18.5
Normal. 18.5 to 24.9
Overweight. 25-29.9
Obese. >30
8. Modules
Mathematical functions – import maths
9. Modules
Random functions – import random
10. Modules
Statistical functions – import stats

11. Iterative construct


Program to print factorial of a user entered number
12. Iterative construct
Program to print Fibonacci series, user to enter number of terms.

3
13. Program to check if user entered number is prime, else print number of
factors.
14 Program to print multiplication table of user entered number.

15. program for dice imitation.

16. program to print the following for the user entered number
1. Sum of digits (while loop)
2. Reverse of a number (Palindrome number (while loop))

17. Implementation of 'break’ and 'continue’. [Unconditional jump statements.

18. Display the following pyramids with the help of nested for loops.
* 1 1
* * 1 2 2 3
*. *. * 1. 2. 3 4. 5. 6
*. *. *. * 1. 2. 3. 4 7. 8. 9. 10

19. Display following pyramids with help of nested ‘while loop’

*. *. *. * *
*. *. * * *
* * *. *. *
* *. *. *. *

20. Write a program to input the values of x and n and print the following series.
(Use pow() )

4
5
Programs

Topics:- Functions

Program Sequential Construct


1:- WAP to read 3 numbers from the user and print the sum and average.

Source print("Kailasapu Karthikeya")


code:- print("Question 1")
print("CBSE 11A")

print("--------------")

a = int (input(" Please Enter the First Number: "))

b = int (input(" Please Enter the second number: "))

c = int (input(" Please Enter the third number: "))

average=(a+b+c)/3

print("The average of three numbers is ", average)

6
Output:-

7
Topics:- Functions

Program 2:- Sequential Construct


WAP to read 2 numbers from user and print maximum number

Source Code print("Kailasapu Karthikeya")


print("Question 2")
print("CBSE 11A")

print("--------------")

a = int(input("Enter the first number: "))


b = int(input("Enter the second number: "))

# printing the maximum value


if(a > b):
print(a, "is greater")
elif(a < b):
print(b, "is greater")
else:
print("Both are equal")

8
Output

9
Topics:- Functions

Program 3:- Selective/ Conditional Construct


WAP to read 3 numbers from user and print maximum number (chaining
of relational operator)

Source Code print("Kailasapu Karthikeya")


print("Question 3")
print("CBSE 11A")

print("--------------")

a = int (input(" Please Enter the First Number: "))

b = int (input(" Please Enter the second number: "))

c = int (input(" Please Enter the third number: "))

if (a>=b) and (a>c):


print(a, "a is largest")
if (b>=a) and (b>=c):
print(b, "b is largest")
else:
print(c, "c is largest")

10
Output

11
Topics:- Functions

Program 4:- Selective/ Conditional Construct


WAP to read 3 numbers from user and print maximum number (nested if

structure)

Source Code print("Kailasapu Karthikeya")


print("Question 4")
print("CBSE 11A")

print("--------------")

a = int (input(" Please Enter A: "))

b = int (input(" Please Enter B: "))

c = int (input(" Please Enter C: "))

#Nested Structure
if a>b: #mainif
if a>c: #nested if
g=a

else:
g=c

else:
if b>c:
g=b

12
else:
g=c

print("Greater is = ",g)

Output

13
Topics:- Functions

Program 5:- Selective/ Conditional Construct


WAP to read 3 numbers from user and print maximum number (combining
conditions with logical operators)

Source Code print("Kailasapu Karthikeya")


print("Question 5")
print("CBSE 11A")

print("--------------")

a = int (input(" Please Enter the First Number: "))

b = int (input(" Please Enter the second number: "))

c = int (input(" Please Enter the third number: "))

if a>b and a>c:


print(a)

elif b>a and b>c:


print(b)

else:
print(c)

14
Output

15
Topics:- Functions

Program 6:- Selective/ Conditional Construct


WAP to simulate 4 function calculator. (nested if structure)
Reads 2 integers and an arithmetic operator and displays the result [
assume values are valid]

Source Code print("Kailasapu Karthikeya")


print("Question 6")
print("CBSE 11A")

print("--------------")

# adds two numbers


def add(x, y):
return x + y

# subtracts two numbers


def subtract(x, y):
return x - y

# multiplies two numbers


def multiply(x, y):
return x * y

# divides two numbers


def divide(x, y):
return x / y

print("-------Calculator-------")
print("Select operation.")

16
print("1.Add")
print("2.Subtract")
print("3.Multiply")
print("4.Divide")

while True:

choice = input("Enter choice(1/2/3/4): ")

if choice in ('1', '2', '3', '4'):


num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))

if choice == '1':
print(num1, "+", num2, "=", add(num1, num2))

elif choice == '2':


print(num1, "-", num2, "=", subtract(num1, num2))

elif choice == '3':


print(num1, "*", num2, "=", multiply(num1, num2))

elif choice == '4':


print(num1, "/", num2, "=", divide(num1, num2))

17
Output

18
Topics:- Functions

Program 7:- Selective/ Conditional Construct


Write a program to calculate
BMI= (weight/height2)
of a person after inputting its weight in kgs and height in meters and then
print the status as
Underweight <18.5
Normal. 18.5 to 24.9
Overweight. 25-29.9
Obese. >30

Source Code print("Kailasapu Karthikeya")


print("Question 7")
print("CBSE 11A")

print("--------------")

# Program to calculate BMI


height = float(input("Enter your height in m: "))
weight = float(input("Enter your weight in kg: "))

bmi= weight / (height)**2

print("Your bmi is :- ",bmi)

if bmi <=18.5:
print("You are Underweight")
elif bmi >=18.5 <=24.9:
print("You are Normal")
elif bmi >=25 <=29.9:

19
print("You are OverWeight")
elif bmi >=30:
print("You are Obese")
else:
print("You are Severely Obese")

Output

20
Topics:- Functions

Program 8:- Modules


Mathematical functions – import maths

Source Code print("Kailasapu Karthikeya")


print("Question 8")
print("CBSE 11A")

print("--------------")

import math

print(math.sqrt(81))
print(math.ceil(87.9))
print(math.ceil(81.8))
print(math.floor(82.4))
print(math.floor(81.9))
print(math.pow(6,10))
print(math.fabs(81))
print(math.fabs(-81))
print(math.sin(81))
print(math.cos(81))
print(math.tan(81))
print(math.pi)

21
Output

22
Topics:- Functions

Program 9:- Modules


Random functions – import random

Source Code

23
Output

24
Topics:- Functions

Program 10:- Modules


Statistical functions – import stats

Source Code print("Kailasapu Karthikeya")


print("Question 10")
print("CBSE 11A")

print("--------------")

# Statistical module
# mean, median, mode

print("Statictical Module")

import statistics

A1=[11,22,33,33,44,55,77]
T1=[12,22,84,84,51,69,99]

# To get mean in a given list


print("original list",A1)
print("mean of list",statistics.mean(A1))
print("original tuple",T1)
print("mean of tuple",statistics.mean(T1))

# To get median in a given list


print("original list",A1)
print("median of list",statistics.median(A1))
print("original tuple",T1)
print("median of tuple",statistics.median(T1))

25
# To get mode in a given list
print("original list",A1)
print("mode of list",statistics.mode(A1))
print("original tuple",T1)
print("mode of tuple",statistics.mode(T1))

Output

26
Topics:- Functions

Program 11:- Iterative construct


Program to print factorial of a user entered number

Source Code print("Kailasapu Karthikeya")


print("Question 11")
print("CBSE 11A")

print("--------------")

num = int(input("Enter a number: "))


factorial = 1
if num < 0:
print("Factorial cant be negative")
elif num == 0:
print("The factorial of 0 is 1")
else:
for i in range(1,num + 1):
factorial = factorial*i
print("The factorial of",num,"is",factorial)

27
Output

28
Topics:- Functions

Program 12:- Iterative construct


Program to print Fibonacci series, user to enter number of terms

Source Code print("Kailasapu Karthikeya")


print("Question 12")
print("CBSE 11A")

print("--------------")

nterms = int(input("Enter terms you want:- "))

# two terms
n1, n2 = 0, 1
count=0

if nterms <= 0:
print("Please enter a positive integer")

elif nterms == 1:
print("Fibonacci sequence upto",nterms,"is :-")
print(n1)

else:
print("Fibonacci sequence upto",nterms,"is :-")
while count < nterms:
print(n1)
nth = n1 + n2
#final values
n1 = n2

29
n2 = nth
count += 1

Output

30
Topics:- Functions

Program 13:- Program to check if user entered number is prime, else print number of
factors.

Source Code print("Kailasapu Karthikeya")


print("Question 13")
print("CBSE 11A")

print("--------------")

num = int (input ("Enter a number : - ") )

# prime numbers are greater than 1


if num > 1:

for i in range (2, num) :


if (num % i) == 0:
print (num, "is not a prime number")

break
else:

print (i, "times", num//i, "is", num)


print ("The factors of ", num, "are: ")
for i in range (1, num + 1) :
if num % i == 0:
print (i)

31
Output

32
Topics:- Functions

Program 14:- Program to print multiplication table of user entered number.

Source Code print("Kailasapu Karthikeya")


print("Question 14")
print("CBSE 11A")

print("--------------")

num = int(input ("Enter the number: "))

print("Multiplication Table of The Number", num,"is :-")

for i in range (1, 11):


print (num, "X",i,"=", num * i)

33
Output

34
Topics:- Functions

Program 15:- Program for dice imitation

Source Code print("Kailasapu Karthikeya")


print("Question 15")
print("CBSE 11A")

print("--------------")

import random
L1 = [1, 2, 3, 4, 5, 6]
print ("random number from dice is:", random.choice (L1))

Output

35
Topics:- Functions

Program 16:- Program to print following for user entered number


1. Sum of digits (while loop)
2. Reverse of a number (Palindrome number (while loop))

Source Code print("Kailasapu Karthikeya")


print("Question 16")
print("CBSE 11A")

print("--------------")

num=int (input ("Enter any number:"))


sum=0
while (num>0):
remaining=num%10
sum=sum+remaining
num=num//10

print("The sum of the digits for given number is:", sum)

print("---------------------------")

n=int(input("Enter any number to check whether it is palindrome:"))


a=0

temp=n

rev=0

36
while n>0:
d = n%10
a = a+d
rev = rev *10 +d
n = n//10
if temp == rev:
print (temp, "is palidrome number")

else:
print (temp, "is not palindrome number")
print (a)

Output

37
Topics:- Functions

Program 17:- Implementation of ‘break’ and ‘continue’. [Unconditional jump statements.

Source Code print("Kailasapu Karthikeya")


print("Question 17")
print("CBSE 11A")

print("--------------")

#BREAK AND CONTINUE

'''
for i in range(1,11):
print(i)
else:

print("Loop Successful")
print("out of loop")
'''

for c in range(1,11):
if c==3:
continue
if c==7:
break
print(c)
else:
print("successful loop")

print("out of loop")

38
Output

39
Topics:- Functions

Program 18:- Display following pyramids with help of nested for loop
* 1 1
* * 1 2 2 3
*. *. * 1. 2. 3 4. 5. 6
*. *. *. * 1. 2. 3. 4 7. 8. 9. 10

Source Code print("Kailasapu Karthikeya")


print("Question 18")
print("CBSE 11A")

print("--------------")

rows = int(input ("Enter number of rows: "))

for i in range (rows) :


for j in range (i+1):
print("* ", end="")
print("\n")

rows = int(input ("Enter number of rows: "))

for i in range (rows) :


for j in range (i+1):
print (j+1, end=" ")
print("\n")

40
rows = int(input ("Enter number of rows: "))
number = 1

for i in range (1, rows+1):


for j in range (1, i+1):
print (number, end=" ")
number += 1
print()

Output

41
Topics:- Functions

Program 19:- Display following pyramids with help of nested ‘while loop’

*. *. *. * *
*. *. * * *
* * *. *. *
* *. *. *. *

Source Code print("Kailasapu Karthikeya")


print("Question 19")
print("CBSE 11A")

print("--------------")

rows = int(input ("Enter number of rows: "))

for i in range (rows, 0, -1):


for j in range (0, i):
print("* ", end=" ")

print("\n")

rows = int(input ("enter number of rows: "))

k = 2*rows - 2

42
for i in range (0, rows):

for j in range (0, k):


print (end=" ")

# decrement
k=k-2

for j in range(0, i+1):

print("* ", end="")


print("\n")

43
Output

44
Topics:- Functions

Program 20:- Write a program to input value of x and n and print the following series. (Use
pow() )

Source Code print("Kailasapu Karthikeya")


print("Question 20")
print("CBSE 11A")

print("--------------")

x = float (input ("Enter value of x :"))


n = int (input ("Enter value of n :"))
s=0

for a in range (n + 1) :
if a%2==0:
s += x**a
else:
s -= x**a
print ("Sum of series", s)

45
print("-------------------------------")

x = float (input ("Enter value of x :"))


n = int (input ("Enter value of n :"))
s=0

for a in range (n + 1) :
if a%2==0:
s += x**a
else:
s -= x**a
print ("Sum of series", s)

print("-------------------------------")

x = float (input ("Enter value of x :"))


n = int (input ("Enter value of n :"))
s=0

for a in range (n + 1) :
if a%2==0:
s += (x**a)/n
else:
s -= (x**a)/n

print ("Sum of series", s)

print("-------------------------------")

46
x = float (input ("Enter value of x :"))
n = int (input ("Enter value of n :"))
s=0
a=1
fact=1
for a in range (1,n + 1) :
fact=fact*a
if a%2==0:
s += (x**a)/fact
else:
s -= (x**a)/fact
print ("Sum of series", s)

47
Output

48
THE END

49

You might also like