Practical File
Of
Problem Solving using
Python Programming
23CS001
Submitted
In partial fulfillment for the award of the degree
Of
BACHELOR OF ENGINEERING
In
COMPUTER SCIENCE & ENGINEERING
CHITKARA UNIVERSITY
CHANDIGARH-PATIALA NATIONAL HIGHWAY
RAJPURA(PATIALA) PUNJAB-140401 (INDIA)
December, 2023
Submitted To: Submitted By:
Faculty Name: Shanky Goel Name: Himanshu Singh
Designation: Professor Roll No: 2310991848
Chitkara University, Punjab Sem, Batch: 1st, 2023-2024
Problem Solving using Python Programming (23CS001)
Problem Solving using Python Programming (23CS001)
INDEX
Sr Practical Name Teacher
No. sign
1. a) Write a Python Program to Calculate the area of a triangle.
b) Write a Python Program to Swap two variables.
c) Write a Python Program to convert Celsius to Fahrenheit.
2. a.) Write a Python Program to Check if a Number is Odd or Even
b.) Write a Python Program to Check if a Number is Positive, Negative or 0
c.) Write a Python program to Check Armstrong Number
3. a.) Write a Python program to print n Fibonacci Numbers.
b.) Write a Python program to print cube sum of first n natural numbers.
c.) Write a Python program to print all odd numbers in a range.
4. a.) Write a Python Program to Print Pascal Triangle
Hint: Enter number of rows: 4
1
1 1
1 2 1
1 3 3 1
b.) WAP to Draw the following Pattern for n number: 1 1 1 1 1
2222
333
44
5
5. Write a program with a function that accepts a string from keyboard and create a new
string after converting character of each word capitalized. For instance, if the sentence
is
“stop and smell the roses” the output should be “Stop And Smell The Roses”
6. a.) Write a program that accepts a list from user. Your program should reverse the
content of list and display it. Do not use reverse () method.
b) Find and display the largest number of a list without using built-in function max().
Your program should ask the user to input values in list from keyboard.
7. Find the sum of each row of matrix of size m x n. For example, for the following matrix
output will be like this:
Sum of row 1 = 32
Sum of row 2 = 31
Sum of row 3 = 63
8. a) Write a program that reads a string from keyboard and display:
* The number of uppercase letters in the string.
* The number of lowercase letters in the string.
* The number of digits in the string.
Problem Solving using Python Programming (23CS001) Page | 1
* The number of whitespace characters in the string.
b) Python Program to Find Common Characters in Two Strings.
c) Python Program to Count the Number of Vowels in a String.
Problem Solving using Python Programming (23CS001) Page | 1
Program 1:
Title of Program: (a) Calculating area of a triangle
Solution:
Output:
Title of Program: (b) Swapping Two Variables
Solution:
Output:
Title of Program: (c) Celsius to Fahrenheit Solution:
Output:
Program 2:
Title of Program: (a) Checking Odd or Even number
Solution: Problem Solving using Python Programming (23CS001)
Problem Solving using Python Programming (23CS001) Page | 3
Problem Solving using Python Programming (23CS001)
Output:
Title of Program: (b) Check if a number is positive, negative or 0
Solution:
Output:
Title of Program: (c) Check Armstrong Number
Solution:
Output:
Program 3:
Title of Program: (a) Print ‘n’ Fibonacci Numbers
Solution:
Output:
Problem Solving using Python Programming (23CS001) Page | 4
Problem Solving using Python Programming (23CS001)
Title of Program: (b) Cube Sum of first n natural numbers
Solution:
Output:
Title of Program: (c) Odd Numbers in a range
Solution:
Output:
Program 4:
Title of Program: (a) Pascal’s Triangle
Solution:
Output:
Title of Program: (b) Pattern for n numbers
Problem Solving using Python Programming (23CS001) Page | 5
Problem Solving using Python Programming (23CS001)
Solution:
Output:
Program 5:
Title of Program: (a) Capitalizing the first word
Solution:
Output:
Program 6:
Title of Program: (a) List Reverse
Solution:
Output:
Problem Solving using Python Programming (23CS001) Page | 6
Problem Solving using Python Programming (23CS001)
Title of Program: (b) Largest Number
Solution:
Output:
Program 7:
Title of Program: Sum of each row of matrix
Solution:
Output:
Program 8:
Title of Program: (a) Reading a String Solution:
Problem Solving using Python Programming (23CS001) Page | 7
Problem Solving using Python Programming (23CS001)
Output:
Title of Program: (b) Common characters in 2 strings
Solution:
Output:
Title of Program: (c) Counting Number of Vowels
Solution:
Output:
Problem Solving using Python Programming (23CS001) Page | 8
Problem Solving using Python Programming (23CS001)
Problem Solving using Python Programming (23CS001) Page | 9