Course Code (RJMAJITP231)
Index
Sr. No Practical Description Date
1 Basics of programming using Python using conditional statements B1-
22/6/26
B2-
24/6/26
a. Create a program that asks the user to enter their name and their age. Print
out a message addressed to them that tells them the year that they will turn
100 years old.
b. Enter the number from the user and depending on whether the number is
even or odd, print out an appropriate message to the user.
c. Write a program to read three numbers from a user and check if the first
number is greater or less than the other two numbers.
d. Write a program that prompts a user to enter two different numbers.
Perform basic arithmetic operations (Add, Subtraction, Multiplication,
Division) based on the choices. (Use If elif)
2 Basics of programming using Python using loops : while, range(), for B1-
loop, Nested loops, Break and continue statement 1/7/26
- DECISION MAKING STATEMENTS - if statements, if-else B2-
statements, Nested if statements, Multi-way if-elif-else 8/7/26
statements
a. Unlock various offers based on cart amount. - Use elif
b. A fitness app rewards users based on the number of steps walked
in a day.
● Less than 3,000: Keep Moving!
● 3,000–6,999: Bronze Badge
● 7,000–9,999: Silver Badge
● 10,000 or more: Gold Badge + 100 Reward Points
Write a Python program to display the reward.
c. Write nested if statements to print the appropriate message
depending on the value of the variables temperature and humidity
as given as follows. Assume that the temperature can only be
warm and cold and the humidity can only be dry and humid.
d. Write a program to read a number from a user and print the
reverse order of the number.
e. Write a program to find the sum of the digits of a given number.
f. Write a program to add 10 consecutive odd numbers starting from
31 using the while loop.
g. Write a program to check a palindrome no.
h. Write a program to check Armstrong's number.
i. Write a program to check prime numbers.
j. Write a program to display the pattern of stars given as follows:
k. Program to demonstrate Break and Continue statement.
3 Strings
Write a program to print only the vowels from a given string. For example
if S is “An Apple”. Output should be “A A e”
Check if a given string is palindrome or not.
Demonstration of String Functions - split(), Format(), isalnum, upper(),
lower(), endswith(), startswith(),
Table 7.1, 7.2, Table 7.3
Write a program to print a given string into ascending order using logic.
Given string” python”
Output- “hnopty”
A pangram is a sentence that contains all the letters of the English
alphabet at least once, for example: The quick brown fox jumps over the
lazy dog.
Your task here is to write a function to check a sentence to see if it is a
pangram or not.
Write the function count_Letter(word, letter) which takes a word and a
letter as arguments and returns the number of occurrences of that letter in
the word.
Write the function startEndVowels(word) which returns True if the word
starts and ends with vowels.
Write a function Eliminate_Letter(word, letter) which takes a word and a
letter as arguments and removes all the occurrences of that particular
letter from the word. The function will return the remaining letters in the
word.
Write a python Code to print the ASCII value of the given Strings
character
# Input string
string = input("Enter a string: ")
# Loop through each character and print its ASCII value
for char in string:
print(f"Character: {char} ASCII Value: {ord(char)}")
4. List
Write a program that takes two lists and returns True if they have at least
one common member.
Write a Python program to print a specified list after removing the 0th,
2nd, 4th and 5th elements.
Write a Python program to clone or copy a list.
Take a list, say for example this one: a=[1,1,2,3,5,8,13,21,34,55,89] and
write a program that prints out all the elements of the list that are less than
5
Write a function check_duplicate(Lst) which returns True if a list Lst
contains duplicate elements. It should return False, if all the elements in
the list Lst are unique.
Write a function Assign_grade(Lst) which reads the marks of a student
from a list and assigns a grade based on the following conditions:
if Marks >=90 then grade A
if Marks >=80 && <90 then grade B
If Marks >65 && < 80 then grade C
if Marks > =40 && <=65 then grade D
if Marks <40 then grade F
Consider the List of Marks of a 5 Student in English Subject.
Lst=[78,90,34,56,89]
#Should return Student 1 Marks 78 grade C
Student 2 Marks 90 grade A
Student 3 Marks 34 grade F
Student 4 Marks 56 grade D
Student 5 Marks 89 grade B
Write a function Extract_Even(List) to return all even numbers from a list.
Write a program to count the occurrences of the world ‘the’. Use split()
and count() functions.
5 Functions
Write a function reverse_number() to return the reverse of the number
entered. Example: Reverse_number(1234) displays 4321
Write a recursive function which computes the nth Fibonacci number.
Write a program to pass the radius of a circle as a parameter to a function
area_of_circle(). Return the value none if the value of the radius is
negative or return the area of the circle.
Write a function to Calculate the factorial of a number using recursion.
For a quadratic equation in the form of ax2+bx+c, the discriminant D, is b2
- 4ac. Write a function to compute the discriminant D, that returns the
following output depending on the discriminant D. if D > 0: The Equation
has two Real Roots if D = 0: The Equation has one Real Root if D < 0:
The Equation has two Complex Roots
Write a function that takes a character (i.e. a string of length 1) and
returns True if it is a vowel, False otherwise
Define a function that computes the length of a given list or string
A pangram is a sentence that contains all the letters of the English
alphabet at least once, for example: The quick brown fox jumps over the
lazy dog. Your task here is to write a function to check a sentence to see if
it is a pangram or not.
Define a procedure histogram () that takes a list of integers and prints a
histogram to the screen. For example, histogram ([4, 9, 7]) should print the
following: **** ********* *******
- DECISION MAKING STATEMENTS:
- Loops : while, range(), for loop
5.3 THE range() FUNCTION
There is an inbuilt function in Python called range(), which is used to generate a list of
integers. The range function has one, two or three parameters. The last two parameters
in range() are optional. The general form of the range function is: range(begin, end, step)
The ‘begin’ is the first beginning number in the sequence at which the list starts. The
‘end’ is the limit, i.e. the last number in the sequence. The ‘step’ is the difference
between each number in the sequence.
list(range(1,6)) [1,2,3,4,5]
5.4 THE for LOOP
5.6 T THE break STATEMENT
The keyword break allows a programmer to terminate a loop. When the break statement is
encountered inside a loop, the loop is immediately terminated and the program control
automatically goes to the fi rst statement following the loop.
5.7 THE continue STATEMENT
The continue statement is exactly opposite of the break statement. When continue is
encountered within a loop, the remaining statements within the body are skipped but the loop
condition is checked to see if the loop should continue or exit.
Example
for i in range(1,11,1):
if i == 5:
continue
print(i, end=” “)
Program to Remove spaces with and without using continue statement:
user_input = input("Enter a string: ") str1=str(input("Please Enter the String: "))
result = "" print(" Entered String is : ", str1)
print(" After Removing Spaces, the String
# Loop through each character becomes: ",end=" " )
for char in user_input: for i in str1:
# Only add the character if it is not a if i==" ":
space continue
if char != " ": print(i, end="")
result += char
print(result) # Output: HelloWorld
Without Continue Using continue
Outer loop, value of i= 1
value of num= 2
inner loop, value of j= 1 value of X= 3
Outer loop, value of i= 2
value of num= 3
inner loop, value of j= 1 value of X= 4
inner loop, value of j= 2 value of X= 4
Outer loop, value of i= 3
value of num= 4
inner loop, value of j= 1 value of X= 5
inner loop, value of j= 2 value of X= 5
inner loop, value of j= 3 value of X= 5
Outer loop, value of i= 4
value of num= 5
inner loop, value of j= 1 value of X= 6
inner loop, value of j= 2 value of X= 6
inner loop, value of j= 3 value of X= 6
inner loop, value of j= 4 value of X= 6
Outer loop, value of i= 4
value of num= 5
inner loop, value of j= 1 value of X= 6
inner loop, value of j= 2 value of X= 6
inner loop, value of j= 3 value of X= 6
inner loop, value of j= 4 value of X= 6
Outer loop, value of i= 5
value of num= 6
inner loop, value of j= 1 value of X= 7
inner loop, value of j= 2 value of X= 7
inner loop, value of j= 3 value of X= 7
inner loop, value of j= 4 value of X= 7
inner loop, value of j= 5 value of X= 7
End of Program
Star Pattern Display
*
* *
* * *
* * * *
* * * * *
End of Program
print(" Star Pattern Display")
num=1
x=num
for i in range(1,6,1):
num=num+1;
#print("Outer loop, value of i=",i)
#print("value of num=",num)
for j in range(1,num,1):
print(" * ",end=" ")
x=num+1
#print("inner loop, value of j=",j,end=" ")
#print("value of X=",x, end=" ")
print()
print("End of Program")