Computer Practical File.
Computer Practical File.
ROLL NO. - 10
CLASS- XI D
COMPUTER SCIENCE PRACTICAL FILE
WAP to swap/exchange values of two variables.
O1
A cloth showroom has announced the
Q2 following festival discounts and the assured
gifts on the purchase of items, based on the
total cost of the items purchased.
Write a Python code to input the total cost of
the items purchased. Calculate and display the
discount and the amount to be paid along with
the assured gift.
x=y
y=x
output:
Enter value of x: 30
Enter value of y: 30
**********************************************************************************
**********************************************************************************
Q2) A cloth showroom has announced the following festival discounts and the assured gifts on the
purchase of items, based on the total cost of the items purchased.
Write a Python code to input the total cost of the items purchased. Calculate and display the
discount and the amount to be paid along with the assured gift.
if(amt>0):
if amt<=5000:
disc = amt*0.05
elif amt<=15000:
disc=amt*0.12
elif amt<=25000:
disc=0.2 * amt
else:
disc=0.3 * amt
print("Discount : ",disc)
else:
print("Invalid Amount")
output:
Enter Sale Amount: 3000
Discount : 150.0
**********************************************************************************
**********************************************************************************
largest = num1
largest = num2
else:
largest = num3
output:
Enter first number: 40
**********************************************************************************
**********************************************************************************
flag = False
if num == 1:
if (num % i) == 0:
flag = True
break
if flag:
else:
output:
Enter a number: 29
29 is a prime number
**********************************************************************************
**********************************************************************************
temp = num
reverse = 0
remainder = temp % 10
if num == reverse:
print('Palindrome')
else:
print("Not Palindrome")
output:
enter a no.30
Not Palindrome
**********************************************************************************
**********************************************************************************
n1, n2 = 0, 1
count = 0
if nterms <= 0:
elif nterms == 1:
print(n1)
else:
print("Fibonacci sequence:")
print(n1)
nth = n1 + n2
n1 = n2
n2 = nth
count += 1
output:
How many terms? 5
Fibonacci sequence:
**********************************************************************************
**********************************************************************************
# print star
print("\r")
output:
*
**
***
****
**********************************************************************************
(B)
A
AB
ABC
ABCD
n=4
for i in range(1,n+1):
A = 97
A += 1
print()
output:
A
AB
ABC
ABCD
**********************************************************************************
(C)
12345
1234
123
12
1
for i in range(6, 1, -1):
print(j, end="")
print()
output:
12345
1234
123
12
1
**********************************************************************************
**********************************************************************************
Q8) WAP to count and display the number of vowels, consonants, uppercase, lowercase
characters in a string.
vowels_list = ['a','e','i','o','u','A','E','I','O','U']
for i in string:
if i in vowels_list:
vowels += 1
if i not in vowels_list:
consonants += 1
if i.isupper():
uppercase += 1
if i.islower():
lowercase += 1
output:
*************************************************************************
*************************************************************************
****************************************************************
Q9) WAP to input a string and determine whether it is a palindrome string or not.
revstr = ""
for i in string:
revstr = i + revstr
if(string == revstr):
else:
output:
**********************************************************************************
**********************************************************************************
Q10) WAP which replaces all vowels in the given string with '*'.
str = input("Enter the string: ")
newStr = ""
for ch in str :
lch = ch.lower()
if lch == 'a' \
or lch == 'e' \
or lch == 'i' \
or lch == 'o' \
or lch == 'u' :
newStr += '*'
else :
newStr += ch
print(newStr)
output:
*ND**
*********************************************
*********************************************