You are on page 1of 9

#Q1 Write a program to enter an integer as a string.

Convert the string into


integer and display the type of value before and after converting to int.

PYTHON CODE

PYTHON OUTPUT

#Q2 Write a program to enter and store the name of three different cities in
three different variables and print all the contents of variables on the
console.

PYTHON CODE

PYTHON OUTPUT

Q3 Make a use of escape sequence character or print() function parameter in


given code to generate desired output.

'''print("Welcome to Power Of Python")

print("Press 1: To run Program1","Press 2: To

run Program2")

print("Press 3: To run Program3 Press 4: To


run Program4")

print(" Press 5: To run Program5") print("Press 6","To run Program6")

print("Press 7")

print("To run Program7")

Output Must be:

Welcome to Power Of Python

Press 1: To run Program1

Press 2: To run Program2


Press 3: To run Program3

Press 4: To run Program4

Press 5: To run Program5

Press 6: To run Program6

Press 7: To run Program7'''

PYTHON CODE

PYTHON OUTPUT

#Q4 Translate the following algorithm into Python code.

'''Step 1: Initialize a variable named Pounds with value 10.

Step 2: Multiply Pounds by 0.45 and assign it to a variable Kilogram.

Step 3: Display the value of variable Pounds and Variable Kilogram.'''

PYTHON CODE

PYTHON OUTPUT

#Q5 Q.5 Make a program for the employee data in the company and enter the
data. Find the data- type of each input. Use the conversion function for
converting data into desired form.

'''emp_id = input("Enter the employee id:") - 1212 emp_name = input("Enter the


employee
name:") Raj

emp_salary = input("Enter the employee salary:"→ 50,000.00 married =


input("Employee Married?

[True|False]:") → False print("check the information")

print("Employee Id:", emp_id)

print("Employee Name:", emp_name) print("Employee Salary:", emp_salary)

print("Employee married:", married) '''

PYTHON CODE

'

PYTHON OUTPUT

#Q6 Change the conversion operator in above question with eval() and print the
data type of each input.

PYTHON CODE

PYTHON OUTPUT

#Q7. Write a program to read two numbers from the user. Apply bitwise &,| and
^ operator on them and display result.

PYTHON CODE
PYTHON OUTPUT

#Q8.State the output of each of the following expression:

'''50/8

50//8

40%5

7%2

4**3'''

PYTHON CODE

PYTHON OUTPUT

#Q9 State the output of each of the following expressions, if each expression
is independent. Assume value X=5

'''X+=10

X-=4

X*=6

X**=2

X%=2

X/=2'''

PYTHON CODE
PYTHON OUTPUT

#Q10. Values assigned to different variables are

'''i = 10

j = 20

k = 40

m = 4

n = 5

Evaluate each of the following Python

expressions. (i) (i + i) * k

(ii) i + (j - n)

(iii) i*j/n

(iv) k/j//5

(v) k+(i^ * n)/ (j - i)'''

PYTHON CODE

PYTHON OUTPUT

#Q11 Evaluate the following statements:

'''A = True

B = True

C = True

D = False

Evaluate each of the following Python

expressions.
(i) print(A and B) (ii) print(B or C)

(iii) print(not A and B and C)

(iv) print(A and not B and not C)

(v) print(not A or not B and not C)'''

PYTHON CODE

PYTHON OUTPUT

#Q12 Consider the following code

'''if i<j:

i=j

else:

i=k

print(i,j,k)

What will be the above code print if the variables i, j and k have the
following values?

a) i=3,j=-5 and k=7

b) =-2.j=-5 and k-9

c) i=8,j=15 and k = 12

d) = 13,j=15 and k = 13

e) i 3.j-15 and k=17'''

PYTHON CODE

PYTHON OUTPUT
#13. Enter the age of 3 people and display the youngest one?

'''a) User input (P1-45, P2-23 and P3-56)

b) User input (P1 = 28, P2 = 66 and P3=80)'''

PYTHON CODE

PYTHON OUTPUT

# Q14 Write a program to Prompt for a score between 0.0 and 1.0. If the Score
is

'''Out of Range, Print an Error. If the score is between 0.0 and 1.0, print a
grade

using the following Table.

Score

Grade

>=0.9 A+

>=0.8 A

>= 0.7 B+

>=0.6 B

>=0.5 C

>=0.4 D
<0.4 F'''

PYTHON CODE

PYTHON OUTPUT

# Q15 Q:4 Write a program to calculate the electricity bill (accept number of
unit from user) in Delhi according to the following criteria

'''Unit Price

First 100 units no charge

Next 100 units Rs. 5 per unit

After 200 units Rs. 10 per unit

Find the price of each of the unit.

1) 250

2) 350

3) 150

4) 99'''

PYTHON CODE

PYTHON OUTPUT
# Q16 Write a program to accept the cost price of a bike and display the road
tax to be paid according to the following criteria:

'''Cost price(In Rs) Tax

>100000 15%

> 50000 and <= 100000 10%

<=50000 5%'''

PYTHON CODE

PYTHON OUTPUT

You might also like