XI - IP Practical File
XI - IP Practical File
For
AISSCE 2024-25 Examination
As a part of the Informatics Practices Course (065)
SUBMITTED BY:
Name:
Roll no. :
Class: XI-B
their sum.
five multiples.
in ascending order.
to 10.
Q16. WAP that accepts and integer and print the sum of its 20
digits.
Q17. WAP to input 2 numbers and print their LCM & GCD. 21
numbers.
Output:
Question3.
Write a program to input a number and print it first five multiples.
Answer:
n=int(input("enter a number:"))
for x in range(n,n*6,n):
print(x)
Output:
Question4.
Write a program that accepts a number and checks whether number is even or
odd.
Answer:
n=int(input("enter a number"))
if(n%2==0):
print("even")
else:
print("odd")
Output:
Question5.
Write a program to read 3 numbers in 3 variables and swap first 2 variables
with the sum of first and second, second and third numbers respectively.
Answer:
a=int(input("enter a no1:"))
b=int(input("enter a no2:"))
c=int(input("enter a no3:"))
a=a+b
b=b+c
print("after swapping the value of a=",a)
print("after swapping the value of b=",b)
Output:
Question6.
Write a program that accepts 3 numbers and print largest of the three.
1) Make use of if-elif
Answer:
n1=float(input("enter a number1:"))
n2=float(input("enter a number2 :"))
n3=float(input("enter a number3 :"))
if(n1>=n2 and n1>=n3):
print("highest n1")
elif(n2>=n1 and n2>=n3):
print("highest n2")
else:
print(n3)
Output :
Question7.
Program that reads 2 numbers and an arithmetic operator and display the result
according to operator.
Answer:
a=float(input("enter first number:"))
b=float(input("enter second number:"))
op=input("enter operator[+-*/%]")
result=0
if op=="+":
print(a+b)
elif op=="-":
print(a-b)
elif op=="*":
print(a*b)
elif op=="/":
print(a/b)
else:
print("invalid operator!!")
print(a,op,b,'=',result)
Output:
Question8. Program to print whether a character is an uppercase/lowercase,
digit or special character.
Answer:
ch=input("enter a character:")
if (ch>="A" and ch<="Z"):
print("uppercase character")
elif (ch>"a" and ch<="z"):
print("lowercase character")
elif (ch>="0"and ch<="9"):
print("you entered digit")
else:
print("you entered special
character")
Output:
Question9. Write a program that read 3 numbers and prints them in ascending
order.
Answer:
Output:
Question10.
Write a program to calculate factorial of a number.
Answer:
def factorial (n):
if n<0:
return 0
elif n==0 or n==1:
return 1
else:
fact=1
while (n>1):
fact *= n
n-=1
return fact
num=5
print("Factorial of",num,"is",factorial(num))
Output:
Question11.
Write a program to print the sum of natural numbers between 1 to 10.
Answer :
sum = 0
Output :
Question12.
Write a program to check whether a number is prime or not.
Answer:
n = int(input("Enter a number: "))
if n > 1:
for i in range(2, n):
if (n % i) == 0:
print("Number is not prime:", n)
break
else:
print("Number is prime")
else:
print("Number is not prime")
Output:
Question13.
Program to print Fibonacci series of first 20 elements.
Answer:
first=0
second=1
print(first)
print(second)
for a in range(1,19):
third=first+second
print(third)
first,second=second,third
Output:
Question14.
Program to print pattern.
Answer:
a) for r in range(1,6):
for c in range(1,r+1):
print ("*",end=" ")
print( )
Output :
b)
for r in range(1,6):
for c in range(1, r + 1):
print(c, end=" ")
print()
Output :
Question15.
Answer:
num = 1234
temp = num
reverse = 0
remainder = num%10
num=num//10
print(reverse)
Output :
Question16.
Write a program that accepta an integer and print the sum of its digits.
Answer:
num = input("Enter an integer: ")
sum = 0
for i in num:
sum += int(i)
print(sum)
Output:
Question17.
Write a program to input 2 numbers and print their LCM and GCD.
Answer:
num1=12
num2=14
for i in range(1,max(num1,num2)):
if num1%i==num2%i==0:
gcd=i
lcm=(num1*num2)//gcd
print("LCM of",num1,"and",num2,"is",lcm)
print("GCD of",num1,"and",num2,"is",gcd)
Output:
Question18.
Write a program that reads a line and tell number of uppercase, lowercase,
alphabets digit.
Answer:
Write a program that reads a line and tell number of uppercase, lowercase,
alphabets digit.
Answer :
s=input("enter a sentence:")
a,d,u,l=0,0,0,0
for c in s:
if c.isalpha():
a=a+1
if c.isdigit():
d=d+1
elif c.isupper():
u=u+1
elif c.islower():
l=l+1
print("no of alphabets=",a)
print("no of digits=",d)
print("no of uppercase letters=",u)
print("no of lowercase letters=",l)
Output :
Question19. Write a program that reads a string and display it in reverse order.
Answer:
string="Hello World"
output=" "
for i in range(len(string)-1,1,-1):
output+=string[i]
output+=string[i-1]
output+=string[i-2]
print(output)
Output:
Question20.
Write a program to find minimum element from a list along with its index in
list.
Answer :
L=[2,58,95,999,65,32,15,17,45]
print(L)
m=min(L)
print("the minimum element is:",m)
print("index of minimum element is:"
,L.index(m))
Output :
Question21.
Write a program to search for an element in a given list of number.
Answer:
mylist=[ ]
print("enter five elements for the list:")
for i in range (5):
val=int(input())
mylist.append(val)
print("enter an elements to be searched:")
elem=int(input())
for i in range(5):
if elem==mylist[i]:
print("/nelement found at index:",i)
print("element found at
position:",i+1)
Output:
Question22.
a) Create a student table and insert data. Implement the following MySQL commands
on the student table:
ALTER table to add new add new attributes/modify data types/drop attribute
UPDATE table to modify data
ORDER BY to display data in ascending /descending order
DELETE to remove tuple(s)
In this post, we are going to create student table and insert 10 student records (data) into
it.Then we will perform some MySQL queries to retrieve data from database. We will alter,
update and order data in ascending and descending order by using MySQL commands. We
will implement following MySQL command on the student table.
Solutions
CREATE TABLE command is used to create table in MySQL. When table is created, its
columns are named; data types and sizes are also supplied for each column. One point is to
be note that each table must have at least one column.
CREATE TABLE STUDENT (RNO INT PRIMARY KEY, NAME VARCHAR (60),
CLASS INT, SECTION VARCHAR (5), GENDER VARCHAR (10), MARKS INT);
In this way create student table with multiple columns. In this table, we declare RNO column
as the primary key of the table. The primary keys cannot allow NULL values.
Create a student table
The INSERT statement adds a new row to table giving value for every column in the
row.
Note that the data values are in same order as the column names in table. We can insert
number of rows into student table. If we want to insert 10 rows into student table then we
need to specify 10 INSERT command to do it.
To add a new column city in the above table with appropriate data type
UPDATE Command
Sometimes we need to change some or all of the values in an existing row. This can be done
using UPDATE command of SQL. WHERE Clause and SET keyword are used with
UPDATE command.
To update single column, one column assignment can be specified with SET clause.
To update multiple columns, multiple columns assignments can be specified with SET
clause.
To increase the marks for the student who have less than 40 by 50%, you could use the
following code
To increase marks by 50% for those students who have marks less than 40
To specify the sort order, we may specify DESC for descending order or ASC for ascending
order. We can perform ordering on multiple attributes or columns
To display Rno, Name, Marks of those Female students in ascending order of their names
To remove all the contents of specific rows, the following command is used.