Basic 11th IP Lab Programs
Basic 11th IP Lab Programs
temp = a
a = b
b = temp
OUTPUT:
Enter an Integer: 2
a= 2b= 3
a= 3b= 2
2
2. Write a program to enter two integers and perform
all arithmetic operations on them.
a = int(input("Enter an Integer: "))
b = int(input("Enter an another Integer: "))
Enter an Integer: 25
a = 25 , b = 6
Addition: 31
Subtraction: 19
3
Multiplication: 150
Division: 4.166666666666667
3. Write a program that prints minimum and maximum
of five numbers entered by the user.
10
if num3 < minimum:
minimum = num3
else:
if num3 > maximum:
maximum = num3
OUTPUT:
OUTPUT:
5x1=5
5 x 2 = 10
5 x 3 = 15 15
5 x 4 = 20
5. Write a program to find the sum of digits of an
integer number, input by the user.
OUTPUT:
17
Enter an integer number: 345
if original_number == reversed_number:
print(original_number, "is a palindrome.")
else:
print(original_number, "is not a palindrome.")
OUTPUT:
18
Enter a number: 12321
12321 is a palindrome.
7. Write a program to print the following patterns:
12345
1234
123
12
12345
1234
123
12 19
1
8. Write a program to input line(s) of text from the user until
enter is pressed. Count the total number of characters in
the text (including white spaces), total number of
alphabets, total number of digits, total number of special
symbols and total number of words in the given text.
(Assume that each word is separated by one space).
# Initialize counters
total_characters = 0
total_alphabets = 0
total_digits = 0
total_special_symbols = 0
total_words = 0
25
for char in line:
if char.isalpha():
total_alphabets += 1
elif char.isdigit():
total_digits += 1
else:
total_special_symbols += 1
OUTPUT:
Results:
Total Characters: 73
Total Alphabets: 56
Total Digits: 4
OUTPUT:
OUTPUT:
33
11. Write a Python program to create a dictionary from a
string.
Note: Track the count of the letters from the string. Sample
string : ‘2nd pu course’
Expected output : {‘ ‘:2, ‘2’:1, ‘n’:1, ‘d’:1, ‘o’:1, ‘p’:1, ‘u’:2, ’c’:1,
‘s’:1, ‘r’:1, ‘e’:1}
Character Counts: {'2': 1, 'n': 1, 'd': 1, ' ': 2, 'p': 1, 'u': 2, 'c': 2, 'o': 1, 'r': 1, 's': 1, 'e': 1}
12. Create a dictionary with the roll number, name and marks of n students
in a class and display the names of students who have marks above 75.
students_dict = {}
# Input student details (roll number, name, and marks) for i in range(n):
{i+1}: ")
name = input(f"Enter name for student {i+1}: ") marks = float(input(f"Enter marks for student {i+1}:
"))
marks}
# Display the names of students with marks above 75 print("Names of students with marks above
75:")
print(details['name'])
OUTPUT:
Enter the number of students: 3 Enter roll number for student 1: 101 Enter name for student 1: aaa
Enter roll number for student 2: 102 Enter name for student 2: bbb Enter marks for student 2: 78
Enter roll number for student 3: 103 Enter name for student 3: ccc
ccc