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

Computer practicle file

The document is a Python programming assignment for Class 11th A at APEX Public School, submitted by a student named Bhavish. It includes a comprehensive index of various programming tasks, each with a corresponding date and source code, covering topics such as arithmetic operations, number manipulation, and string processing. The document serves as a collection of exercises aimed at enhancing programming skills in Python for the academic year 2024-25.

Uploaded by

darshgupta391
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)
4 views

Computer practicle file

The document is a Python programming assignment for Class 11th A at APEX Public School, submitted by a student named Bhavish. It includes a comprehensive index of various programming tasks, each with a corresponding date and source code, covering topics such as arithmetic operations, number manipulation, and string processing. The document serves as a collection of exercises aimed at enhancing programming skills in Python for the academic year 2024-25.

Uploaded by

darshgupta391
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/ 52

APEX PUBLIC SCHOOL

PYTHON FILE
CLASS 11TH A
2024-25

Submitted by: Submitted to:


Bhavish Avnish Shukla
Roll no. 16 PGT IT
Index
Q QUESTION DATE
NO SIGN
WAP to print hello world 07/08/2024
1
WAP to find the sum of two no. 07/08/2024
2
WAP to find the sum of two no. 08/08/2024
3 entered by the user.
WAP to enter value of a and b and 08/08/2024
4 perform all arithmetic operations.
WAP to find the time in hrs and mins if 08/08/2024
5 the time is given in min.
WAP to convert degree Celsius into 09/08/2024
6 degree Fahrenheit.
WAP to calculate speed when values 09/08/2024
7 of distance and time is entered by the
user.
WAP to calculate time given in sec 09/08/2024
8 To hrs,min and sec.
WAP to swap two no. using third 13/08/2024
9 variable value are entered by the
user.
WAP to swap two no. without using 13/08/2024
10 third variable where value are entered
by the user.
WAP to create reverse of two digit no. 17/08/2024
11
WAP to create reverse of three digit 17/08/2024
12 no.
WAP to find difference of two no. 22/08/2024
13
WAP to find the largest no. entered by 22/08/2024
14 the user.
WAP to find smallest no. entered by 22/08/2024
15 the user.
WAP to check the given no. is even or 22/08/2024
16 odd.
WAP to find the value of n factorial 23/08/2024
17 where the value is entered by the
user.
WAP to print the table of n. 23/08/202
18
WAP to find the sum of all number up 02/09/2024
19 to n.
WAP to print all even no up to n. 02/09/2024
20
21 WAP to find whether a number is 07/09/2024
prime or not
22 WAP to find all the factors of n 07/09/2024
23 WAP to print all odd numbers up to n 07/09/2024
24 WAP to print the give pattern 07/09/2024
25 WAP to print the give pattern 07/09/2024
26 WAP to calculate electricity bill on the 07/09/2024
bases of given condition
27 WAP to reverse a number with n no. 07/09/2024
of digits
28 WAP to check if a number is a 07/09/2024
palindrome or not
29 WAP to check if a number is a 07/09/2024
armstrong or not
30 WAP to print the given pattern up to n 07/09/2024
31 WAP to print all the characters of the 4/11/2024
string entered by user individually
32 WAP to print a imputed string 5/11/2024
character by character in reverse
order
33 WAP to print all the vowel present in 5/11/2024
the string
34 WAP to count all the consonants in 5/11/2024
the string
35 WAP to count digits present in given 5/11/2024
string
36 WAP to count no. of words in the 7/11/2024
entered string
37 WAP to count the no. of the occurring 7/11/2024
in the given string (you cannot use
count() function)
38 WAP to separate user name & server 7/11/2024
name from the entered email
39 WAP to count the upper case 7/11/2024
character , lower case
character ,space , digits , special
symbols.
40 WAP to find a no. is palindrome or not 7/11/2024
41 WAP to create a list of a values taken 15/11/2024
from user and print the no. that are
divisible by 5
42 WAP to find sum of all element 15/11/2024
entered in the list
43 WAP to create a tuple of n elements
and then create another tuple having 25/11/2024
the values increased by 5
44 WAP to create a tuple of n elements 25/11/2024
and the sum of all odd elements in the
tuple created
45 WAP that generates a string for the 25/11/2024
tuple ,if the value in the tuple is
even ,it adds a ‘*’ in the even string . If
the value is odd , it should add ‘#’ in
the odd string
46 WAP to input 2 tuples in which there 26/11/2024
can be n values and swap them
47 WAP to find the sum of all element 26/11 2024
that are divisible by 2&3 both
48 WAP to create a tuple and find the 26/11/2024
largest no. from the tuple
49 WAP to create a tuple and find the 27/11/2024
smallest no. from the tuple
50 WAP to input names of ‘n’ employee 27/11/2024
and their salary details like basic
salary , house rent , conveyance
allowance etc. write total salary of
each employee and display where
names are keys.
Q1. WAP to print hello world.
Source Code
print("hello world")

print("Class 11th A , Name - Bhavish , Roll no. 16")

OUTPUT
Q2. WAP to find the sum of the two number.
Source Code
x = 10
y = 9

print("sum is", x + y )

print("Class 11th A , Name - Bhavish , Roll no. 16")

OUTPUT
Q3. WAP to find sum of two numbers entered by the user.
Source Code
x = int(input("enter first number "))
y = int(input("enter second number "))

print("sum is", x + y )

print("Class 11th A , Name - Bhavish , Roll no. 16")

OUTPUT
Q4. WAP to enter a value of A and B and perform all
arithematic operation.
Source Code
x = int(input("Enter first number "))
y = int(input("Enter second number "))

print("Sum is", x + y)
print("Difference is", x - y)
print("Product is", x * y)
print("Division", x / y)
print("Remainder is", x % y)

print("Class 11th A , Name - Bhavish , Roll no. 16")

OUTPUT
Q5. WAP to find the time in hours and minutes when time
is in minutes.
Source Code
x = int(input("Enter time in minutes "))

print("Number of hours:", x // 60)


print("Number of minutes are:", x % 60)

print("Class 11th A , Name - Bhavish , Roll no. 16")

OUTPUT
Q6. WAP to convert degree Celsius to degree Fahrenheit.

Source Code

x = int(input("Enter temprature in degree Celsius "))


print("Temprature in Fahrenheit:", x * 9/5 +32 )

print("Class 11th A , Name - Bhavish , Roll no. 16")


OUTPUT
Q7. WAP to calculate speed when value of distance and
time is entered by the user.
Source Code
x = int(input("Enter Distance travelled in meters "))
y = int(input("Enter time taken in seconds "))

print("Speed is", x / y ,"m/sec" )


print("Class 11th A , Name - Bhavish , Roll no. 16")

OUTPUT
Q8. WAP to calculate given time in seconds to hours ,
minutes and seconds.
Source Code
x = int(input("Enter time in seconds "))

print("Time in hours is:", x // 3600,)


print("Time in minutes is:", x // 60,)
print("Time in seconds is:", x % 60,)

print("Class 11th A , Name - Bhavish , Roll no. 16")


OUTPUT
Q9. WAP to swap two number value entered by the user
by using third variable.
Source Code
print(f"Values before swapping are: first value is {x} and second value is {y}" )
z = x
x = y
y = z

print(f"Values after swapping are: first value is {x} and second value is {y}" )

print("Class 11th A , Name - Bhavish , Roll no. 16")

OUTPUT

Q10. WAP to swap two number value are entered by the


user without using the third variable.
Source Code
x = int(input("Enter first number "))

y = int(input("Enter second number "))

print(f"Values before swapping are: first value is {x} and second value is
{y}" )
x , y = y , x

print(f"Values after swapping are: first value is {x} and second value is
{y}" )

print("Class 11th A , Name - Bhavish , Roll no. 16")

OUTPUT

Q11. WAP to create a reverse of two digit number.


Source Code
x = int(input("Enter a two digit number "))

y = x % 10
y = y * 10
y = y + x // 10
print("reverse value is", y)

print("Class 11th A , Name - Bhavish , Roll no. 16")


OUTPUT
Q12. WAP to create a reverse of three digit number.
Source Code
x = int(input("Enter a three digit number "))

y = x % 10
y = y * 10
x = x // 10
y = y + x % 10
y = y * 10
y = y + x // 10
print("reverse value is", y)

print("Class 11th A , Name - Bhavish , Roll no. 16")


OUTPUT
Q13. WAP to find difference of two number.
Source Code
def main():
x = int(input("Enter first number "))
y = int(input("Enter second number "))

print("difference is", x - y )
print("Class 11th A , Name - Bhavish , Roll no. 16")

main()

OUTPUT
Q14. WAP to find largest number entered by the user.
Source Code
x = int(input("Enter first number "))
y = int(input("Enter second number "))

if x > y:
print("x is greater than y")
else:
print("y is greater than x")

print("Class 11th A , Name - Bhavish , Roll no. 16")


OUTPUT
Q15. WAP to find out the smallest number where the
numbers are entered by the user.
Source Code
x = int(input("Enter first number "))
y = int(input("Enter second number "))

if x < y:
print("x is smaller than y")
else:
print("y is smaller than x")

print("Class 11th A , Name - Bhavish , Roll no. 16")

OUTPUT
Q16. WAP to check the given number is even or odd.
Source Code
x = int(input("Enter first number "))

if x % 2 == 0:
print("Given number is even")
else:
print("Given number is odd")

print("Class 11th A , Name - Bhavish , Roll no. 16")

OUTPUT

Q17. WAP to find the value of n factorial where the value


is entered by the user.
Source Code
x = int(input("Enter first number "))
f = 1
while x > 0:
f = f * x
x = x - 1
print("factorial of x =", f)
print("Class 11th A , Name - Bhavish , Roll no. 16")

OUTPUT
Q18. WAP to print the table of n.
Source Code
x = int(input("Enter a number "))
y = 1

while y <= 10:


print(x * y)
y = y + 1

print("Class 11th A , Name - Bhavish , Roll no. 16")


OUTPUT
Q19. WAP to find the sum of all number up to n.
Source Code
x = int(input("Enter a number "))
y = 0
z = 1
while z <= x:
y = y + z
z = z + 1

print("Sum is", y)

print("Class 11th A , Name - Bhavish , Roll no. 16")


OUTPUT
Q20. WAP to print all even no up to n.
Source Code
x = int(input("Enter a number "))
y = 2

while y <= x:
print(y)
y = y + 2

print("Class 11th A , Name - Bhavish , Roll no. 16")

OUTPUT

Q21. WAP to find whether a number is prime or not


Source Code
x = int(input("Enter a number "))
if x == 2 or x == 3 or x == 5:
print("Prime")
elif x % 2 != 0 and x % 3 != 0 and x % 5 != 0:
print("Prime")
else:
print("Not prime")

print("Class 11th A , Name - Bhavish , Roll no. 16")

OUTPUT
Q22. WAP to find all the factors of n
Source Code
n = int(input("Enter a number: "))

factors = []
for i in range(1, n + 1):
if n % i == 0:
factors.append(i)

print("The factors of", n, "are:", factors)


print("Class 11th A , Name - Bhavish , Roll no. 16")

OUTPUT
Q23. WAP to print all odd numbers up to n
Source Code
x = int(input("Enter a number "))
y = 2

while y <= x:
print(y)
y = y + 2

print("Class 11th A , Name - Bhavish , Roll no. 16")

OUTPUT
Q24. WAP to print the give pattern
Source Code
def pyramid_of_stairs(n):
for i in range(1, n+1):
print(" ".join("*" * i))

pyramid_of_stairs(5)

print("Class 11th A , Name - Bhavish , Roll no. 16")

OUTPUT

Q25. WAP to print the give pattern


Source Code
n = 5

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


print(" " * (n - i), end="")
print("*" * i)

print("Class 11th A , Name - Bhavish , Roll no. 16")

OUTPUT
Q26. WAP to calculate electricity bill on the bases of given
condition
Source Code
x = int(input("enter number of units: "))

if 0 <= x <= 200:


print("Your electricity bill is:",x * 5 + 10/100 * x)
elif 201 <= x <= 400:
print("Your electricity bill is:",x * 8 + 10/100 * x)
else:
print("Your electricity bill is:",x * 10 + 10/100 * x )

print("Class 11th A , Name - Bhavish , Roll no. 16")

OUTPUT
Q27. WAP to reverse a number with n no. of digits
Source Code
number = int(input("Enter a number: "))

reversed_number = 0

while number > 0:


remainder = number % 10
reversed_number = reversed_number * 10 + remainder
number = number // 10

print(f"Reversed number: {reversed_number}")

print("Class 11th A , Name - Bhavish , Roll no. 16")

OUTPUT
Q28. WAP to check if a number is a palindrome or not
Source Code
number = int(input("Enter a number: "))

original_number = number

reversed_number = 0

while number > 0:


remainder = number % 10
reversed_number = reversed_number * 10 + remainder
number = number // 10

if original_number == reversed_number:
print(f"{original_number} is a palindrome.")
else:
print(f"{original_number} is not a palindrome.")

print("Class 11th A , Name - Bhavish , Roll no. 16")

OUTPUT
Q29. WAP to check if a number is a armstrong or not
Source Code
number = int(input("Enter a number: "))

original_number = number

num_digits = len(str(number))

sum_of_powers = 0

while number > 0:


digit = number % 10
sum_of_powers += digit ** num_digits
number = number // 10

if sum_of_powers == original_number:
print(f"{original_number} is an Armstrong number.")
else:
print(f"{original_number} is not an Armstrong number.")

print("Class 11th A , Name - Bhavish , Roll no. 16")

OUTPUT
Q30. WAP to print the given pattern up to n
Source Code
n = int(input("Enter the number of rows: "))

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


print("*" * i)

print("Class 11th A , Name - Bhavish , Roll no. 16")

OUTPUT
Q31. WAP to print all the characters of the string entered
by user individually
Source Code
s = input("Enter a string: ")
sp = s.split()
print(sp)

print("Class 11th A , Name - Bhavish , Roll no. 16")

OUTPUT

Q32. WAP to print a imputed string character by


character in reverse order
Source Code
s = input("Enter a string: ")

print("The string in reverse order is:")


for char in reversed(s):
print(char)

print("Class 11th A , Name - Bhavish , Roll no. 16")


OUTPUT
Q33. WAP to print all the vowel present in the string
Source Code
input_string = input("Enter a string: ")
vowels_list = []
vowels = "aeiouAEIOU"
print("Vowels in the string are:")
for char in input_string:
if char in vowels:
vowels_list.append(char)
print(vowels_list)

print("Class 11th A , Name - Bhavish , Roll no. 16")

OUTPUT
Q34. WAP to count all the consonants in the string
Source Code
input_string = input("Enter a string: ")
vowels_list = []
vowels = "aeiouAEIOU "
print("Vowels in the string are:")
for char in input_string:
if char in vowels:
continue
else:
vowels_list.append(char)
print(vowels_list)

print("Class 11th A , Name - Bhavish , Roll no. 16")

OUTPUT
Q35. WAP to count digits present in given string
Source Code
input_string = input("Enter a string: ")

digit_count = 0

for char in input_string:


if char.isdigit():
digit_count += 1

print(f"The number of digits in the string is: {digit_count}")

print("Class 11th A , Name - Bhavish , Roll no. 16")

OUTPUT
Q36. WAP to count no. of words in the entered string
Source Code
input_string = input("Enter a string: ")

word_count = len(input_string.split())

print(f"The number of words in the string is: {word_count}")

print("Class 11th A , Name - Bhavish , Roll no. 16")


OUTPUT
Q37. WAP to count the no. of the occurring in the given
string (you cannot use count() function)
Source Code
input_string = input("Enter a string: ")
input_string = input_string.lower()
words = input_string.split()
the_count = 0
for word in words:
if word == "the":
the_count += 1
print(f"The word 'the' occurs {the_count} times in the string.")

print("Class 11th A , Name - Bhavish , Roll no. 16")

OUTPUT
Q38. WAP to separate user name & server name from
the entered email
Source Code
email = input("Enter your email address: ")

username, server_name = email.split("@")

print(f"Username: {username}")
print(f"Server Name: {server_name}")

print("Class 11th A , Name - Bhavish , Roll no. 16")


OUTPUT
Q39. WAP to count the upper case character, lower case
character, space, digits, special symbols.
Source Code
input_string = input("Enter a string: ")
upper_count = lower_count = space_count = digit_count = special_count = 0

for char in input_string:


if char.isupper():
upper_count += 1
elif char.islower():
lower_count += 1
elif char.isspace():
space_count += 1
elif char.isdigit():
digit_count += 1
else:
special_count += 1

print(f"Uppercase characters: {upper_count}")


print(f"Lowercase characters: {lower_count}")
print(f"Spaces: {space_count}")
print(f"Digits: {digit_count}")
print(f"Special symbols: {special_count}")

print("Class 11th A , Name - Bhavish , Roll no. 16")

OUTPUT
Q40. WAP to find a no. is palindrome or not
Source Code
num = int(input("Enter a number: "))
temp = num
reverse = 0

while num > 0:


reverse = reverse * 10 + num % 10
num = num // 10

if temp == reverse:
print("Palindrome")
else:
print("Not Palindrome")

print("Class 11th A , Name - Bhavish , Roll no. 16")

OUTPUT
Q41. WAP to create a list of a values taken from user and
print the no. that are divisible by 5
Source Code
n = int(input("Enter number of elements: "))
values = []

for i in range(n):
value = int(input("Enter a value: "))
values.append(value)

for val in values:


if val % 5 == 0:
print(val)

print("Class 11th A , Name - Bhavish , Roll no. 16")

OUTPUT
Q42. WAP to find sum of all element entered in the list
Source Code
n = int(input("Enter number of elements: "))
values = []

for i in range(n):
value = int(input("Enter a value: "))
values.append(value)

sum_of_elements = sum(values)
print("Sum of all elements:", sum_of_elements)

print("Class 11th A , Name - Bhavish , Roll no. 16")

OUTPUT
Q43. WAP to create a tuple of n elements and then
create another tuple having the values increased
by 5
Source Code
n = int(input("Enter number of elements: "))
original_tuple = tuple(int(input("Enter a value: ")) for _ in range(n))

increased_tuple = tuple(x + 5 for x in original_tuple)

print("Original Tuple:", original_tuple)


print("Increased Tuple:", increased_tuple)

print("Class 11th A , Name - Bhavish , Roll no. 16")

OUTPUT
Q44. WAP to create a tuple of n elements and the sum
of all odd elements in the tuple created
Source Code
n = int(input("Enter number of elements: "))
values_tuple = tuple(int(input("Enter a value: ")) for _ in range(n))

odd_sum = sum(x for x in values_tuple if x % 2 != 0)

print("Sum of all odd elements:", odd_sum)

print("Class 11th A , Name - Bhavish , Roll no. 16")

OUTPUT
Q45. WAP that generates a string for the tuple ,if the
value in the tuple is even ,it adds a ‘*’ in the even
string . If the value is odd , it should add ‘#’ in the
odd string
Source Code
n = int(input("Enter number of elements: "))
values_tuple = tuple(int(input("Enter a value: ")) for _ in range(n))

even_string = ""
odd_string = ""

for x in values_tuple:
if x % 2 == 0:
even_string += "*"
else:
odd_string += "#"

print("Even String:", even_string)


print("Odd String:", odd_string)

print("Class 11th A , Name - Bhavish , Roll no. 16")

OUTPUT
Q46. WAP to input 2 tuples in which there can be n
values and swap them
Source Code
n1 = int(input("Enter number of elements for the first tuple: "))
tuple1 = tuple(int(input("Enter a value: ")) for _ in range(n1))

n2 = int(input("Enter number of elements for the second tuple: "))


tuple2 = tuple(int(input("Enter a value: ")) for _ in range(n2))

tuple1, tuple2 = tuple2, tuple1

print("First Tuple after swap:", tuple1)


print("Second Tuple after swap:", tuple2)

print("Class 11th A , Name - Bhavish , Roll no. 16")

OUTPUT
Q47. WAP to find the sum of all element that are divisible
by 2&3 both
Source Code
n = int(input("Enter number of elements: "))
values = []

for i in range(n):
value = int(input("Enter a value: "))
values.append(value)

sum_divisible = sum(x for x in values if x % 2 == 0 and x % 3 == 0)

print("Sum of elements divisible by both 2 and 3:", sum_divisible)

print("Class 11th A , Name - Bhavish , Roll no. 16")

OUTPUT
Q48. WAP to create a tuple and find the largest no. from
the tuple
Source Code
n = int(input("Enter number of elements: "))
values_tuple = tuple(int(input("Enter a value: ")) for _ in range(n))

largest_number = max(values_tuple)

print("Largest number in the tuple:", largest_number)

print("Class 11th A , Name - Bhavish , Roll no. 16")

OUTPUT
Q49. WAP to create a tuple and find the smallest no.
from the tuple
Source Code
n = int(input("Enter number of elements: "))
values_tuple = tuple(int(input("Enter a value: ")) for _ in range(n))

smallest_number = min(values_tuple)

print("Smallest number in the tuple:", smallest_number)

print("Class 11th A , Name - Bhavish , Roll no. 16")

OUTPUT
Q50. WAP to input names of ‘n’ employee and their
salary details like basic salary , house rent ,
conveyance allowance etc. write total salary of
each employee and display where names are keys.
Source Code
n = int(input("Enter number of employees: "))
employee_data = {}

for _ in range(n):
name = input("Enter employee name: ")
basic_salary = float(input(f"Enter basic salary for {name}: "))
house_rent = float(input(f"Enter house rent for {name}: "))
conveyance_allowance = float(input(f"Enter conveyance allowance for
{name}: "))

total_salary = basic_salary + house_rent + conveyance_allowance


employee_data[name] = total_salary

for name, total_salary in employee_data.items():


print(f"Total salary of {name}: {total_salary}")

print("Class 11th A , Name - Bhavish , Roll no. 16")

OUTPUT

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