0% found this document useful (0 votes)
2 views5 pages

Program of Python

JKSKILLHUB PVT. LTD. outlines a series of Python programming tasks focused on problem-based learning, covering basic programs, control statements, loops, string manipulation, list methods, dictionary operations, and function creation. The document includes specific programming challenges such as calculating areas, checking eligibility, and manipulating strings and lists. Each section provides detailed instructions for developing various programs to enhance Python skills.

Uploaded by

nk1108439
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)
2 views5 pages

Program of Python

JKSKILLHUB PVT. LTD. outlines a series of Python programming tasks focused on problem-based learning, covering basic programs, control statements, loops, string manipulation, list methods, dictionary operations, and function creation. The document includes specific programming challenges such as calculating areas, checking eligibility, and manipulating strings and lists. Each section provides detailed instructions for developing various programs to enhance Python skills.

Uploaded by

nk1108439
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

JKSKILLHUB [Link].

JKSKILLHUB PVT LTD


Problem based learning in Python
Mentor : Dr. Jasdeep Kaur

Problem 1 : Develop following basic programs in python to display on the screen and to
do some calculations

1. Write a program to display any message on the screen.


2. Write a program to read one integer, one Float, one Character type variable and
display the values of all three variables.
3. Write a program to read two integers, calculate sum, difference, product and division
of them and display the result.
4. Write a program to read radius of a circle, calculate its area and display the result.
(area = pi*r*r)
5. Write a program to read base and height of a triangle, calculate its area and display
the result. (area = ½*base*height)
6. Write a Program to convert days into years
7. Write a program to read side of a square, calculate its area and display the result.
(area = side*side)
8. Write a program to read length and width of a rectangle, calculate its area and display
the result. (area = length*width)
9. Write a program to calculate simple interest. (SI = principal*rate of interest*time/100)
10. Swap numbers
a. Swap two numbers using third variable.
b. Swap two numbers without using third variable.
11. Write a program to read marks obtained and maximum marks of a student and
calculate its percentage and display it.
12. Write a program to read two integers, divide them and store the result in third integer
type variable and display the value of all three variables.
13. Write a program to read two integers, divide them and store the result in third float
type variable and display the value of all three variables.
14. Write a program to read one integer, one float divides them and store the result in
third integer type variable and display the value of all three variables.
15. Write a program to read one integer, one float divides them and store the result in
third float type variable and display the value of all three variables.
16. Write a program to Convert temperature in Celsius to Fahrenheit . ((0C * 9/5)+32)
17. Write a program to convert Years into Days.
18. Write a program to Convert kilometres per hour to miles per hour.(1km = 0.6213712)

1
JKSKILLHUB [Link].

Problem 2 : Develop the following programs in python using control statement.

 If-else

1. Write a program to determine whether a person is eligible to vote.


2. Write a program to find maximum between two numbers.
3. Write a program to check whether a number is positive and negative.
4. Write a program to check whether a character is alphabet or not.

 If – elif – else

1. Write a program to find maximum between three numbers.


2. Write a program to input any character and check whether it is alphabet,
digit or special character.
3. Write a program to input any alphabet and check whether it is vowel or
consonant.
4. Write a program to input marks of five subjects Physics, Chemistry,
Biology, Mathematics and Computer. Calculate percentage and grade.

 Nested if

1. Write a program to check whether a number is divisible by 5 and 11 or not.


2. Write a program to check whether a number is divisible by 2, 5 and 6 or
not.
3. Let us write a program to input three numbers from user. Find maximum
between given three numbers

Program 3 : Develop the following programs in python using control statement (Loops).

 For-loop
 Write a program to display the “Hello world” n times.
 Write a program to find the first 10 natural numbers.
 Write a program to find the sum of 10 natural numbers.
 Write a program to find the factorial of a number.
 Write a program to display the multiplication table.
 Write a program to check if a number is prime or not.
 Write a program to display the:
1
12
123
1234
12345
 Write a program to display the:

2
JKSKILLHUB [Link].

*
***
*****
*******
*********

 While-loop

 Write a program to display the “Hello world” n times.


 Write a program to display Fibonacci series.
 Write a program to check a number is palindrome or not.
 Write a program to display the:

*
**
***
****
*****
 Write a program to display the:

1
22
333
4444
55555
 Write a program to display the:

*
***
*****
*******
*********

Program 4 : Develop the following programs in python using string .

1. Write a Python program to calculate the length of a string.


2. Program to read a string and display it in reverse order-display one character
per line do not create a reverse string, just display in reverse order.
3. Program to read a string and display it in the form:

3
JKSKILLHUB [Link].

For ex: „Try‟


T y
r r
y T
4. Program that displays this the following pattern without using any nested loop.
#
##
###
####
#####
5. Write a program to input a string and check if it is a palindrome string using a
string slice.
 String Functions in python :-

 lower(): Converts all uppercase characters in a string into lowercase


 upper(): Converts all lowercase characters in a string into uppercase
 title(): Convert string to title case
 swapcase(): Swap the cases of all characters in a string
 capitalize(): Convert the first character of a string to uppercase
 index(): Returns the position of the first occurrence of a substring in a string
 isalnum(): Checks whether all the characters in a given string is alphanumeric
or not.
 isalpha(): Returns “True” if all characters in the string are alphabets
 isdecimal(): Returns true if all characters in a string are decimal
 isdigit(): Returns “True” if all characters in the string are digits
 replace(): Replaces all occurrences of a substring with another substring

 List Methods in Python:-

 append(): Used for appending and adding elements to the end of the List.
 copy(): It returns a shallow copy of a list
 clear(): This method is used for removing all items from the list.
 count(): These methods count the elements
 extend(): Adds each element of the iterable to the end of the List
 index(): Returns the lowest index where the element appears.
 insert(): Inserts a given element at a given index in a list.
 pop(): Removes and returns the last value from the List or the given index
value.
 remove(): Removes a given object from the List.
 reverse(): Reverses objects of the List in place.
 sort(): Sort a List in ascending, descending, or user-defined order

4
JKSKILLHUB [Link].

 min(): Calculates the minimum of all the elements of the List


 max(): Calculates the maximum of all the elements of the List
 Write a program to read and display 2-D array.
 Write a program to Add two matrices.
 Write a program to subtract two matrices.
 Write a program to check whether a matrix is symmetric or not.
(A matrix is symmetric if A[i][j] == A[j][i])
 Write a program to product of two matrices.
 Write a program to transpose of matrices.

 Python Dictionary :-

 clear(): Removes all Items


 copy(): Returns the Shallow Copy of a Dictionary
 get(): Returns Value of The Key
 items(): returns view of dictionary's (key, value) pair
 keys(): Returns View Object of All Keys
 pop() : removes and returns element having given key
 popitem(): Returns & Removes Latest Element From Dictionary
 update(): Updates the Dictionary values()
 Write a Python program to count the number of characters (character
frequency) in a string.
 program to get a string from a given string where all occurrences of its first
char have been changed to '$', except the first char itself.
 program to remove characters that have odd index values in a given string.
 Python program to remove a newline in Python.

Program 5 : Develop the following programs in python using function .

1. Write a program to create a function that takes two arguments, name and age, and
display their value.
2. Write a Python function to sum all the numbers in a list.
3. Write a Python function to find the maximum of three numbers.
4. Write a Python function to multiply all the numbers in a list.
5. Write a Python program to reverse a string.
6. Write a function that inputs a number and display this the multiplication table of that
number.

You might also like