- Write program to input any number and to print all factors of that number.
- Write a program to input any number and to check whether given number is Armstrong or not. (Armstrong 1,153,etc. 13 =1 , 13+53 +33 =153)
- Write a program to input employee no, name basic pay and to find HRA, DA and netpay.
Basic pay Hra Da
>100000 15% 8%
<=100000&>50000 10% 5%
<=50000 5% 3%
- Write a program to find all prime numbers up to given number.
- Write a program to convert decimal number to binary.
- Write a program to convert binary to decimal.
- Write a program to input two complex numbers and to find sum of the given complex numbers.
- Write a program to input two complex numbers and to implement multiplication of the given complex numbers.
- Write a program to find sum of two distances with feet and inches.
- Write a program to find difference between two times with hours, minutes and seconds.
- Write a program to find the sum of all digits of the given number.
- Write a program to find the reverse of that number
- Write a program to input username and password and to check whether the given username and password are correct or not.
- Which string method is used to implement the following:
a) To count the number of characters in the string.
b) To change the first character of the string in capital letter.
c) To check whether given character is letter or a number.
d) To change lower case to upper case letter.
e) Change one character into another character.
- Write a program to input any string and to find number of words in the string.
- Write a program to input any two strings and to check whether given strings are equal are not.
- Write a program to input n numbers and to insert any number in a particular position.
- Write a program to input n numbers and to search any number.
- Write a program to find area of following using function overloading.
- Area of circle (function with one parameter)
- Area of rectangle (function with two parameters)
- Area of triangle (function with three parameters)
- Write a program to find out volume of the following using function overloading.
- volume of cube
- volume of cuboid
- volume of cylinder
- Create the class SOCIETY with following information:
An __init__ method to assign initial values of society_name as "Surya Apartments", flat as "A Type", house_no as 20, no_of_members as 3, income as 25000.
Inputdata( ) - to read data members (society, house_no, no_of_members & income) and call allocate_flat().
allocate_flat( ) - To allocate flat according to income
>=25000 A Type
>=20000 and <25000 B Type
<15000 C Type
Showdata( ) - to display the details of the entire class.
- Define a class ITEMINFO in Python with the following description:
ICode (Item Code)
Item (Item Name)
Price (Price of each item)
Qty (quantity in stock)
Discount (Discount percentage on the item)
Netprice (Final Price)
A member function FindDisc( ) to calculate discount as per the following rule:
If Qty<=10 Discount is 0
If Qty (11 to 20) Discount is 15
If Qty>=20 Discount is 20
A constructor( __init__ method) to assign the value with 0 for ICode, Price, Qty, Netprice and Discount and null for Item respectively
A function Buy( ) to allow user to enter values for ICode, Item, Price, Qty and call function FindDisc( ) to calculate the discount and Netprice(Price*Qty-Discount).
A Function ShowAll( ) to allow user to view the content of all the data members.
- Define a class furniture in Python with the given specifications:
getType() To return instance variable Type
getModel()To return instance variable Model
show() To print instance variable Type and Model
Define a class sofa:
getSeats() To return instance variable No_of_seats
getCost() To return instance variable Cost
show() To print instance variable No_of_seats and Cost
This class inherits class furniture
- Define a class student in Python with the given specifications:
Roll number, name
Getdata()- To input roll number and name
Printdata()- To display roll number and name
Define another class marks, which is derived from student class
Marks in five subjects
Inputdata() - To call Getdata() and input 5 subjects marks.
Outdata() - To call printdata() and to display 5 subjects marks.
- File Handling
- Creating copy of a file.
- Write a function that takes three argument 1st input file, 2nd output file and 3rd transformation function. First argument is the file opened for reading, second argument is the file opened for writing
and third argument is a function, which takes single string and performs a transformation of your choice and returns the transformed string. The function should reed each line in the input file, pass
the line through transformation function and then write transformed line to output file. A transformation can be - capitalize first alphabet of every word.
- Write a function to create a text file containing following data
Neither apple nor pine are in pineapple. Boxing rings are square.
Writers write, but fingers don't fing. Overlook and oversee are opposites. A house can burn up as it burns down. An alarm goes off by going on.
i) Read back the entire file content using read() or readlines () and display on screen.
ii) Append more text of your choice in the file and display the content of file with line numbers
prefixed to line.
iii) Display last line of file.
iv) Display first line from 10th character onwards
v) Read and display a line from the file. Ask user to provide the line number to be read.
- Create a dictionary having decimal equivalent of roman numerals. Store it in a binary file. Write a function to convert roman number to decimal equivalent using the binary file data.
- Write a program to delete the content provided by user from the binary file. The file is very large and can't fit in computers memory.
- Write a program to read a file 'Story.txt' and create another file, storing an index of Story.txt telling which line of the file each word appears in. If word appears more than once, then index should show all the line numbers containing the word.
Hint : Dictionary with key as word(s) can be used to solve this.
- Write a function called replace file(), that takes pattern string, replacement string and two file names as argument. The function should read the first file and write the content into second file (creating it, if necessary). If the pattern string appear anywhere in first file, it should be replaced by replacement string in second file.
- Write a program to accept a filename from the user and display all the lines from the file which contain python comment character '#'.
- Reading a file line by line from beginning is a common task, what if you want to read a file backward. This happens when you need to read log files. Write a program to read and display content of file from end to beginning.
- Create a class item to store information of different items, existing in a shop. At least following is to be stored w.r.t. each item code, name, price, qty. Write a program to accept the data from user and store it permanently in the file. Also provide user with facility of searching and updating the data in file based on code of item.