0% found this document useful (0 votes)
3 views6 pages

Programming With Python

The document provides a series of simple Python programs and explanations of various functions such as print(), input(), type(), int(), and float(). It includes examples of how to use these functions, as well as application-based questions and additional programming tasks. The content is aimed at beginners learning Python programming concepts and syntax.

Uploaded by

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

Programming With Python

The document provides a series of simple Python programs and explanations of various functions such as print(), input(), type(), int(), and float(). It includes examples of how to use these functions, as well as application-based questions and additional programming tasks. The content is aimed at beginners learning Python programming concepts and syntax.

Uploaded by

amitapramanik05
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

PYTHON SIMPLE PROGRAMS

D1. What is IDLE Editor window? Write steps to open it.


In IDLE Editor window, we can write, edit, debug, run
and save programs. It is a text editor.
Steps:
Click at Start  All Programs
Click at IDLE Python (3.8)
D2. What is the use of print() function? Give example.
print() is used to display the result.
Example:
A=1
B=2
print(A)
print(A,B)
print(“Value of A: “,A)
print(A,”+”,B,”=”,(A+B))
print(A,”\t”,B)
print(a,b,end=",")
print(a,b,sep=",")
[Link] is the use of input() function? Give example.
input() function is used to accept the value of a variable
at run time.
X=input(“Enter your name”)
[Link] is the use of type() function? Give example.
type() function is used to know what data type is
assigned to a variable.
Example:
>>>type(x)
[Link] is the use of int() function? Give example.
int() function is used to convert specific value to
integer.
x=int(input(“Enter a number”))
y=3.14
z=int(y)
D6) What is the use of float() function? Give example.
float() function is used to convert specific value to float.
x=float(input(“Enter a number”))

Application based question:


E1) for i in range(10,15,1):
print(i,end=',')

Output:
10,11,12,13,14,

E2) for i in range(0.5,5.5,0.5):


print(i)
Output:
TypeError: 'float' object cannot be interpreted as an
integer

E3. Precedence from Highest to Lowest:


** , % , & , >

E4. n=int(input(“Enter the last term:”))


Sum=0
for I in range(0,n+1):
if I%3==0 || I%5==0 :
print(I,end= “,”)
Sum=Sum+I
print(“Sum=”,Sum)

Extra:
1. Write a program to initialize value of two variables and add those two
values.
a=13
b=14
c=a+b
print(c)
a=13
b=14
c=a+b
print(a,"+",b,"=",c)

2. Write a program to accept two numbers and display their sum.


A=int(input(“Enter 1st number”))
B=int(input(“Enter 2nd number”))
C=A+B
print(A,”+”,B,”=”,C)

3. Write a program to accept a number and display square of the number.


N=int(input(“Enter the number”))
R=N**2
print(“Square of ”,N,”=”,R)
Output:
Enter the number 4
Square of 4 = 16

4. Write a program to accept two numbers m and n and display mn.


M=int(input(“Enter the value of m”))
N=int(input(“Enter the value of n”))
R=M**N
print(R)

Write a program to accept temperature in Celsius and display in Fahrenheit.


C=float(input(“Enter temperature in Celsius”))
F=9*C/5+32
print (“Temperature in Celsius:”,C)
print (“Temperature in Fahrenheit:”,F)

6. Write a program to accept the two numbers and display the result using
operators + - * / % **and //.
A=int(input(“Enter the 1st number”))
B=int(input(“Enter the 2nd number”))
print(A,”+”,B,”=”,A+B)
print(A,”-”,B,”=”,A-B)
print(A,”*”,B,”=”,A*B)
print(A,”/”,B,”=”,A/B)
print(A,”//”,B,”=”,A//B)
print(A,”**”,B,”=”,A**B)

7. Write a program to accept a number and display the multiplication table of


the number.
A=int(input(“Enter a number”))
for I in range(1,11):
r=A*I
print(A,” x ”,I,” = ”, r)

8. Write a program to display sum of odd numbers between 1 and 20.


sum=0
for I in range(1,20,2):
sum=sum+I
print(“Sum = “,sum)
for i in range(10,15,1):
print(i,end=',')
Output:
10,11,12,13,14,
for i in range(0.5,5.5,0.5):
print(i)

You might also like