x-practical
x-practical
X practical
if char.isalpha():
if char.isupper():
print(char, "is an uppercase letter.")
else:
print(char, "is a lowercase letter.")
elif char.isdigit():
print(char, "is a digit.")
else:
print(char, "is a special character.")
3.
Write a program to find the maximum number out of the given three
numbers.
4.
500 and above Rs. 650 plus Rs. 1.75 per unit in excess of 50
amount = consumed_units * 1
elif 101 <= consumed_units <= 300:
amount = 100 + (consumed_units - 100) * 1.25
elif 301 <= consumed_units <= 500:
amount = 350 + (consumed_units - 300) * 1.50
else:
amount = 650 + (consumed_units - 500) * 1.75
5.
Write a program to check whether the entered number is Armstrong
or not.
num_str = str(number)
num_digits = len(num_str)
if sum_of_digits == number:
print(number, "is an Armstrong number.")
else:
print(number, "is not an Armstrong number.")\
6.
Write a program to print a multiplication table of the entered
number.
7.
Write a program to generate the following pattern:
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
current_number = 1
num_rows = 5
8.
Write a program to create a list of students’ marks with user-
defined values and find the maximum
marks = [ ]
for i in range(num_students):
mark = float(input(f"Enter the mark for student {i+1}: "))
marks.append(mark)
max_mark = max(marks)
9.
Write a program to create a list of numbers and swap the content
with the next value divisible by 5.
numbers = []
for i in range(num_elements):
num = int(input("Enter number: "))
numbers.append(num)
10.
Write a program to count the frequency of every element in a given
list
elements = elements_input.split()
frequency = {}
print("Frequency of Elements:")
for element, count in frequency.items():
print(element, ":", count)