Practical List - Python [ 4330701 ] [ PRACTICAL EXERCISES ] - Computer Bits Daily

Python Program Example
Practical Outcomes : Environment Setup
1 Install and configure the Python environment. Run basic Python commands to verify the Python environment - Click to learn more
   
Practical Outcomes : Input-Output
1 PYTHON PROGRAM TO PRINT "HELLO PYTHON LEARNER" - Click to learn more
2 Write a program to read your name, contact number, email, and birthdate and print those details on the screen. - Click to learn more
Practical Outcomes : Variables, operators, Expressions
1 Write a program to convert temperature from Celsius to Fahrenheit. Equation to convert Celsius to Fahrenheit: F = (9/5) * C + 32. - Click to learn more
2 Python program to convert Fahrenheit to Celsius. [ Formula : Celsius = (Fahrenheit – 32) * 5/9 ] - Click to learn more
3 Write a program to compute the slope of a line between two points (x1, y1) and (x2, y2). [ slope = y2-y1/x2-x1 ] - Click to learn more
4 Write a program to calculate simple and compound interest.[ Simple interest = (P * N * R)/100, Compound interest =P * (pow((1 + R / 100), N))
5 WRITE A PROGRAM TO GET CHANGE VALUES IN QUARTER, DIME, NICKELS AND PENNIES, AND CALCULATE THE VALUE OF CHANGE IN DOLLARS. CONSIDER QUARTER = 0.25 $, DIME = 0.10 $, NICKELS = 0.05 $ AND PENNY = 0.01 $.
6 WRITE A PROGRAM TO FIND A MAXIMUM OF GIVEN THREE NUMBERS (USE TERNARY OPERATOR).
7 WRITE A PROGRAM TO CALCULATE AREA AND VOLUME OF SPHERE. [ AREA OF SPHERE =4ΠR², VOLUME OF THE SPHERE =(4/3)*ΠR³.]
8 WRITE A PROGRAM THAT COMPUTES THE REAL ROOTS OF A GIVEN QUADRATIC EQUATION (USE MATH LIBRARY). [ DISCRIMINANT = B^2-4AC , THE ROOTS ARE {-B + √(B^2 – 4AC)}/2A AND {-B – √(B^2 – 4AC)}/2A.]
9 WRITE A PROGRAM TO DETERMINE THE LENGTH OF LADDER REQUIRED TO REACH A GIVEN HEIGHT WHEN LEANED AGAINST THE HOUSE. THE HEIGHT AND THE ANGLE OF THE LADDER ARE GIVEN AS INPUTS (USE MATH LIBRARY).
Practical Outcomes : Decision-Making Structures
1 A year is a Leap year if it is divisible by 4, unless it is a century year that is not divisible by 400 (1800 and 1900 are not leap years, 1600 and 2000 are leap years). Write a program that calculates whether a given year is a leap year or not.
2 Many companies pay time-and-a-half for any hours worked above 40 hours in a given week. Write a program to input the number of hours worked and hourly rate and calculate the total wages for the week.
3 The Body Mass Index (BMI) is calculated as a person's weight (in kg), divided by the square of the person's height (in meters). If the BMI is between 19 and 25, the person is healthy. If the BMI is below 19, then the person is underweight. If the BMI is above 25, then the person is overweight. Write a program to get a person's weight (in kgs) and height (in cms) and display a message whether the person is healthy, underweight or overweight. [ BMI = (Weight in Kilograms / (Height in Meters x Height in Meters)) ]
4 Write a program to read the marks and assign a grade to a student. Grading system: A (>=90), B (80-89), C (70-79), D (60-69), E (50-59), F (<50). (Use the Switch case)
Practical Outcomes : Loops
1 Write a program to read n numbers from users and calculate the average of those n numbers.
2 Write a program that prompts the user to enter 10 integers and displays all the combinations of picking two numbers from the 10.
3

Write programs to print below patterns:

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

1
1 2
1 2 3
1 2 3 4
1 2 3 4 5

       1
     22
   333
 4444
55555


4 Write a program that displays an ASCII character table from ! to ~. Display the ASCII value of a character in decimal and hexadecimal. Display five characters per line.
5 Write a program to sum the following series: 1/3 + 3/5 + 5/7 + 7/9 + 9 /11 + 11/ 13 + ... + 95 /97 + 97 /99
6 A positive integer is called a perfect number if it is equal to the sum of all of its positive divisors, excluding itself. For example, 6 is the first perfect number, because 6 = 3 + 2 + 1, and the next is 28 = 14 + 7 + 4 + 2 + 1. There are four perfect numbers that are less than 10,000. Write a program to find these four numbers.
Practical Outcomes: Lists
1

Write a program to perform the below operations on the list:

- Create a list.

- Add/Remove an item to/from a list.

- Get the number of elements in the list.

- Access elements of the list using the index.

- Sort the list.

- Reverse the list.

2

Write a program to read n numbers from a user and print:

- Number of positive numbers.

- Number of negative numbers.

- Number of zeros.

- Number of odd numbers.

- Number of even numbers.

- Average of all numbers.

3 Write a program that counts the occurrences of each digit in a string. The program counts how many times a digit appears in the string. For example, if the input is "12203AB3", then the output should output 0 (1 time), 1 (1 time), 2 (2 times), 3 (2 times).
4 Write a program to eliminate duplicate values in the list.
5 Write a program to randomly fill in 0s and 1s into a 4x4 2-dimension list, print the list and find the rows and columns with the most number of 1s.
Practical Outcomes : Tuples, Sets and Dictionaries
 Write a python program to perform below operations on tuple:
Create a tuple with different data types.
Print tuple items.
Convert tuple into a list.
Remove data items from a list.
Convert list into a tuple.
Print tuple items.

 2  Write a program to perform below operations on set:
Create two different sets with the data.
Print set items.
Add/remove items in/from a set.
Perform operations on sets: union, intersection, difference, symmetric difference, check subset of another set.

Write a program to perform the below operations on the dictionary:
Create a dictionary.
Print dictionary items.
Add/remove key-value pair in/from a dictionary.
Check whether a key exists in a dictionary.
Iterate through a dictionary.
Concatenate multiple dictionaries.
 
 4Write a program that is given a dictionary containing the average daily temperature for each day of the week, and prints all the days on which the average temperature was between 40 and 50 degrees.                                                                                                                                       
 5 Write a program to repeatedly prompt the user to enter the capital of a state. Upon receiving the user’s input, the program reports whether the answer is correct. Assume the states and their capitals are stored in dictionaries as key-value pairs.  
Practical Outcomes: Function
 1 Write a program that defines a function (shuffle) to scramble a list into a random order, like shuffling a deck of cards.                                                                                                                    
 2 Write a program that defines a function to return a new list by eliminating the duplicate values in the list.                                                                                                                                                 
 3 Write a program to print Fibonacci sequences up to n numbers using recursion. The Fibonacci sequence is defined as below:

Fibonacci sequence: 1 1 2 3 5 8 13 21
                                                                                                                                                        
4 Write a program that defines a function to determine, whether input number n is prime or not. A positive whole number n > 2 is prime, if no number between 2 and √n (inclusive) evenly divides n. If n is not prime, the program should quit as soon as it finds a value that evenly divides n.                                                                                                                                   
 5  Write a python program that defines a function to find the GCD of two numbers using the algorithm below. The greatest common divisor (GCD) of two values can be computed using Euclid's algorithm. Starting with the values m and n, we repeatedly apply the formula: n, m = m, n%m until m is 0. At that point, n is the GCD of the original m and n (Use Recursion).                                                                                                                                                             
6 Write a program that lets the user enter the loan amount, number of years, and interest rate, and defines a function to calculate monthly EMI, total payment and display the amortization schedule for the loan.                                                                                                                                                             
                                                                                                                                                               

Post a Comment

0 Comments