0% found this document useful (0 votes)
304 views

Python Exercise

This document outlines an assignment for a Python programming course. It includes 10 theory questions about Python features, variables, program structure, type casting, and operators. It also includes 10 programming problems to write Python code for calculating areas of shapes, performing math operations, interest calculation, time conversion, and salary calculation. Students are instructed to answer all questions individually without copying from others.

Uploaded by

ganduri narmada
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
304 views

Python Exercise

This document outlines an assignment for a Python programming course. It includes 10 theory questions about Python features, variables, program structure, type casting, and operators. It also includes 10 programming problems to write Python code for calculating areas of shapes, performing math operations, interest calculation, time conversion, and salary calculation. Students are instructed to answer all questions individually without copying from others.

Uploaded by

ganduri narmada
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Assignment -1

Python Programming
 Need to answers all questions. Do not copy from others. if anybody copied from
others will be awarded zero marks.
 Write all the questions in an order

 Theory questions:
1. List out all python features and its applications?
2. What is a variable and variable constant? Explain each with example?
3. Write steps how to write a python program?
4. What is a type-casting? How many types are there?
5. Define the following words:
a. comments
b. multiple assignments
c. indentation
d. statement
e. Escape sequence
6. List out operators available in python? Each with one example?

 Programming problems:
1. Write a python program to calculate area of triangle using Herno’s formula:

# Python Program to find the area of triangle


# Three sides of the triangle a, b and c are provided by the user

a = float(input('Enter first side: '))


b = float(input('Enter second side: '))
c = float(input('Enter third side: '))

# calculate the semi-perimeter


s = (a + b + c) / 2

# calculate the area


area = (s*(s-a)*(s-b)*(s-c)) ** 0.5
print('The area of the triangle is %0.2f' %area)

2. Write a python program to perform addition, Subtraction, Multiplication, Division,


Module on two user input integer numbers?
3. Write a python program to calculate area of a circle?

PI=3.14
radius=float(input("Enter the radius of circle"))
area=PI*radius*radius
print (area)

4. Write a program to calculate the bill amount for an item given its quantity sold,
value, discount?

item_name = input('Enter item name : ')


item_quantity = int(input('Enter item quantity : '))
item_price = float(input('Enter item price : '))
print('**************BILL******************')
print('Item Name \t Item Quantity \t Item Price')
print('\n\t%s \t\t %d \t\t %f' %item_name,item_quantity,item_price))
#print('Item Name\tItem Quantity\tItem Price')
#print ("{}\t \t{}\t \t{}".format(item_name,item_quantity,item_price))
print('***************************************')
print('Total Amount to be paid : %f' %(item_quantity * item_price))
print('***************************************')

5. Write a program to swap two numbers without using third variable?


6. Write a program to read two floating point numbers. Add these numbers and assign
the result to an integer. Finally display the value of all the three variables?
7. Write a program to find SI and CI?
P = float(input('Enter principal amount : '))
R = float(input('Enter rate of interest : '))
T = float(input('Enter time : '))
N = int(input('Enter number of times interest is computed annually : '))
SI = P + (P*R*T)/100
print('Simple interest : %.2f' % SI)
CI = P * pow(1 + (R/N),(N*T))
print('Compound interest : %.2f' % CI)

8. Write a program that calculates number of seconds in a day?

No of days = 1
No of hours = 24
No of minutes = 60
time_in_secs = (days * hours * minutes)*60
print("The number of seconds in a day is:", time_in_secs)

9. Write a program to calculate salary of an employee given his Basic pay (take user
input), HRA=10% and TA=5% of Basic pay. Then calculate the salary of employee?
basic_pay = float(input('Enter basic salary : '))
HRA = 0.1 * basic_pay
TA = 0.05 * basic_pay
salary = basic_pay + HRA + TA
print('Total Salary : %f' % salary)
10. Write a program to String concatenate and repetition?

You might also like