Professional Documents
Culture Documents
ACA-2[2019]
SCHOOL :SOE DEPT.: PET DATE:8.2.2020
SEMESTER/YEAR:6/2020
COURSE INSTRUCTOR: Mr. K PRUDHVI RAJ, Assi. Prof. GANGA
AFTER EXECUTION OF EVERY PROGRAM MAKE SURE YOU WRITE IN YOUR OBSERVATION NOTES
ALONG WITH OUTPUT.
Note: This Program is returning the type of those a, b, c variable, even though we didn’t declare it’s type python
automatically taking it. Understand that
Q2. Type below python program in Spyder editor, save it with file name reading.py, run it.[5 min]
a= input()
b= input()
c= a+b
print(c)
Note
input() is one function which will help us to read values while program in running. So after execution as program is waiting
for you input, give two input values and note down the output.
Note:
Because input is returning string type not integer type so result is not expected.
Note:
output is as expected we are changing string type to int type with extra function int()
Q5. Change Q4 as below and observe the difference.[3 min]
a=int(input("Enter a value"))
b=int(input("Enter b value"))
c=a+b
print(c)
Note:
Input() function has optional parameters that is like above. It will print on screen.
Extra line are printed before reading some value.
Q6. Change Q5 like below and observe the difference.[3 min]
a=int(input("Enter a value"))
b=int(input("Enter b value"))
c=a+b
print("C value is",c)
Note:
Extra string is printed before result.
Note down the variations in print() from previous question.
Operators in Python
Arithmetic Operators
Relational operators
Logical operators
Arithmetic Operators:
Q7. Open new file in Spyder editor, type the below program which reads two values from user and perform all Arithmetic
operations. Fill in the blanks with Proper syntax, save it as arithmetic.py, run it.[10 min]
c=int(_______ ())
d=int(_______())
add=c+d
sub=c-d
mul=c*d
div=c/d
mod=c%d
Input1:
25
Input2:
25
Q8. Open new file in Spyder editor, type the below program which reads two values from user and perform some
relational operations. Fill in the blanks with Proper syntax, save it with relaiton1.py, run it.[8 min]
a=int(input("Enter a number"))
c=a<b
d=a>b
Input1:
Input2:
10
10
Q9. Change in Q8 instead of c=a<b type c=a<=b, and instead of d=a>b type d=a>=b. Save it and run it.[5 min]
Input1:
Input2:
10
10
Q10. Type below program in Spyder editor, save it and run it.[5 min]
re1=0 and 0
re2=0 and 1
re3=1 and 0
re4=1 and 1
print("re1 is ",re1)
print("re2 is ",re2)
print("re3 is ",re3)
print("re4 is ",re4)
Q11. Change Q11 program and to or and save it, run it [5 min]
Q12. Type below program in Spyder editor, which reads age of a person and check whether he/she is eligible to vote or
not in India.[10 min]
if(age>=18):
print("Eligible")
else:
print("Not eligible")
print("Thank you.")
Q13. Write a python program to check weather student is pass or fail in one subject. Pass criteria is 35 marks out of 100.
Hint:
Q14. Write a python program to check whether given input is “heat” or not. Read string from user. Compare with heat if
satisfy print true if not false.[10 min]
temp=input("Enter a string")
if(temp == 'heat'):
print("True")
else:
print("False")
Note: