0% found this document useful (0 votes)
3 views2 pages

JSDPracticals 2025

The document contains a series of Python programming exercises, including checking if a number is odd or even, calculating simple interest, checking for palindromes, generating Fibonacci series, finding the largest of three numbers, summing natural numbers, and creating dictionaries and tuples. Each exercise is presented with code snippets and explanations. The document serves as a practical guide for learning basic Python programming concepts.

Uploaded by

businessd610
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)
3 views2 pages

JSDPracticals 2025

The document contains a series of Python programming exercises, including checking if a number is odd or even, calculating simple interest, checking for palindromes, generating Fibonacci series, finding the largest of three numbers, summing natural numbers, and creating dictionaries and tuples. Each exercise is presented with code snippets and explanations. The document serves as a practical guide for learning basic Python programming concepts.

Uploaded by

businessd610
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/ 2

1)check number is odd or even 7)Write a python program to calculate the

1)n = int(input("Enter a number: ")) simple interest earned for a given amount at a
if n % 2 == 0: given rate of interest for a given number of
print(n, "is Even") years.
else:
p = float(input("Enter the Principal amount: "))
print(n, "is Odd")
r = float(input("Enter the rate of interest: "))
2)check a given string is palindrome or not
y = float(input("Enter the time in years: "))
s = input("Enter a string: ") si = (p * r * y) / 100
if s == s[::-1]: print("Simple Interest is", si)
print(s, "is a palindrome")
else: 8)To check a given character is vowel or not.
print(s, "is not a palindrome") char = input("Enter a character: ").lower()
if char in 'aeiou':
3) to print the fibonacci series up to a given limit. print(char, "is a vowel.")
limit = int(input("Enter limit for Fibonacci series: ")) else:
a, b = 0, 1 print(char, "is not a vowel.")
while a <= limit:
print(a) 9)to check a given number is prime or not.
a, b = b, a + b n = int(input("Enter a number: "))
if n < 2:
4) find the biggest of three numbers. print(n, "is not a prime number.")
a = float(input("Enter the first number: ")) else:
b = float(input("Enter the second number: ")) for i in range(2, n):
c = float(input("Enter the third number: "))
if n % i == 0:
if a >= b and a >= c:
print(a, "is largest")
print(n, "is not a prime number.")
elif b >= a and b >= c: break
print(b, "is largest") else:
else: print(n, "is a prime number.")
print(c, "is largest")

5) print the sum of first N natural numbers


n = int(input("Enter a number N: "))
s=0
for i in range(1, n + 1):
print(i)
s=s+i
print("Sum =", s)

6)find the sum and average of any three


numbers.
a = float(input("Enter the first number: "))
b = float(input("Enter the second number: "))
c = float(input("Enter the third number: "))
s=a+b+c
average = s / 3
print("Sum =", s)
print("Average =", average)
II 6)Create a dictionary using list1 = [1,2,3,4] as
1)Python program using function to find the key and list2= [“Red”,”Blue”,”Green”,”Yellow”]
factorial of a given number. as values.
list1 = [1, 2, 3, 4]
def fact(n): list2 = ["Red", "Blue", "Green", "Yellow"]
r=1 dict1 = {}
for i in range(1, n + 1): for i in range(len(list1)):
r = r*i dict1[list1[i]] = list2[i]
return r print(dict1)

n = int(input("Enter a number: ")) 7)Create a student dictionary and add 5


if n < 0: elements into it, with roll number as key and
print("Factorial is not defined for negative name as value. Display the elements of the
numbers.") dictionary.
else: dict1 = {
f = fact(n) 1: "Alan",
print("Factorial =",f) 2: "Albin",
3: "Basil",
2)Write a python program to create a list using 4: "Charles",
first 5 natural numbers. Print the list in reverse 5: "Don"
order. }
print(dict1)
list = [1, 2, 3, 4, 5]
print("List in reverse order:", list[::-1]) 8) Write a python program to create the tuple
(50, 25, 5, 37, 100 ). Using built in functions
3)Write a python program to create a list fruits display the sum, maximum and minimum value
[“Mango”,”Apple”,”Grape”,”Banana”]. Create of the tuple.
a tuple using the last 3 elements of the fruits list. tup1 = (50, 25, 5, 37, 100)
print("Sum = ", sum(tup1))
list = ["Mango", "Apple", "Grape", "Banana"] print("Maximum value = ", max(tup1))
tup = tuple(list[1:]) print("Minimum value =", min(tup1))
print("Tuple =", tup)

4)Write a python program to count the number


of occurrence of letter ‘a’ in a given string.
str = input("Enter a string: ")
c = str.lower().count('a')
print("Count =", c)

5)Create two tuples with 3 elements each. Swap


and print the elements of both the tuple.
tup1 = (1, 2, 3)
tup2 = ('a', 'b', 'c')
tup1, tup2 = tup2, tup1
print("Swapped Tuple 1:", tup1)
print("Swapped Tuple 2:", tup2)

You might also like