0% found this document useful (0 votes)
86 views3 pages

C

The document contains sample Python code and questions related to Python programming. It includes examples of using type(), int(), float(), print() functions and arithmetic, relational and logical operators. Programming questions test concepts like calculating simple interest given principal, rate and time, finding average temperature for a week, converting seconds to minutes and seconds format, calculating total sales given quarterly sales amounts, and working capital calculation for a company.

Uploaded by

Mritunjay Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
86 views3 pages

C

The document contains sample Python code and questions related to Python programming. It includes examples of using type(), int(), float(), print() functions and arithmetic, relational and logical operators. Programming questions test concepts like calculating simple interest given principal, rate and time, finding average temperature for a week, converting seconds to minutes and seconds format, calculating total sales given quarterly sales amounts, and working capital calculation for a company.

Uploaded by

Mritunjay Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

(C) print (type (int(”123”))) (d) pi = 3.

14

print (type (int(”Hello”))) print (type (pi))

print (type (str(”i23.Ø”))) print (type (“3.14”))

print (type (float (“3.14”)))

print (type (f loat( “tHree point

(e) print (“Hello’ + 2) (J) print (“Hello”/2)

print (“Hello” + “2”) print (“Hello” / 2)

print (“Hello” * 2)

Type C : Progromjg Practice/Knowledge based Questions

Write a program to obtain principal amount, rate of interest and hme


from user and compute Simple intrest

interest.

a proam to obtain temperatures of 7 days (Monday, Tuesday ... Smday)


d then average temperature of the week.

J,’1 Write a program tHat reads a number of seconds and prints it in


form : miris and secon200 seconds are printed as 3 mins and 20 seconds.
[Hint, use 1/ and % to get mini

4J( Write a program that takes sales for four quarters and then
displays total sales

5.,6Vrite a program to calculate working capital for company A that


has

received of about 1,50,000 and inventories of about

of 3,00,000, short terni borrowings of and accri

IHint. Working Capital Current assets _ Current liai,

as per form Prepared By: Sanjeev Bhadauria & Neha Tyaqi


Q.5 What will be the output of the following?
x,y=4, 8

z=x/y*y

print (z)

Ans: 4.0

Q.6 WAP to take value of x,y,z from the user and calculate the equation 4x4
+ 3$ + 9z2 + 6u

Ans: x=int(input(”Enter x : “))

y=int(input(”Enter y : “))

z=int(input(”Enter z : “))

f=4tpow(x, 4) +3tpow(y, 3) +9pow(z, 2) +6*3.14

print(”The Answer is : “If)

Q.7 WAP to take the temperatures of all 7 days of the week and displays the
average

temperature of that week.

Ans: dl=int(input(”Temperature of day 1 : “))

d2=int(input(”Temperature of day 2 : “))

d3=int(input(”Temperature of day 3 : “))

d4=int(input(”Temperature of day 4 : “))

d5=int(input(”Temperature of day 5 : “))

d6=int(input(”Temperature of day 6 : “))

d7=int(input(”Temperature of day 7 : “))

avg= (dl+d2+d3+d4+d5+d6+d7) /7

print(”The average temp is : “,avg)

Chapter - 5: CONDITIONAL AND ITERATIVE STATEMENTS

Short Answer Type Questions

Q.1 What a range() function does? Give an example.

Ans: The range() function returns a sequence of numbers, starting from O by


default, and increments

by 1 (by default), and ends at a specified nurnber. its syntax is


range(start, stop, step) e.g.

x = range(3, 6) x = range(1, 10,2)

forn mx: forn mx:


print(n) print(n)

#This code will print 3 4 5 #This code will print 1 3 5 7 9

Q.2 What are loops in Python? How many types of loop are there in Python?

Ans: Loops are iteration constructs in Python. Iteration means repetition


of a set of statements

depending upon a condition test. Loops has three basic elements within it
to repeat the statements —

. Initialization (Start)

. Check Condition (Stop)

. Updation (Step)

Python provide two types of loop

(i) Conditional Loop while( (Condition based loop)

(ii) Counting loop for (loop for a given number of times).

Q.3 What is the syntax of if-elif statement in Python?

Ans: The syntax of if-elif statement in python is as follows:

If condition 1:

#code-block of statements when condition 1 is true

elif condion2:

#code-block of statements when condition2 is true


ql = tnt(input(’Enter sates quarter 1 :

q2 = int(input(’Enter sates quarter 2 :

q3 = tnt(input(’Enter sates quarter 3 :

q4 = int(input(’Enter sates quarter 4 :

prtnt(Total sates =‘, ql+q2+q3+q4)

prtnt( Avg. sa1,es

You might also like