PF Lec2
PF Lec2
1. Calculate 2x^2
area=½*h*b
How to write a program
5. Calculate 2^3
Required ???????????
How to write a program
num = 458.541315
print('%.2f' % num)
How to write a program
n = float(input())
n = int(input())
C=input()
C=int(c )
a=5
b = 10
x+y : addition
x-y : subtraction
x*y : multiplication
x/y : division
x**y : power
Generalized syntax:
if condition:
#dothis
else:
#dothis
Conditional Statements
Equals: a == b
Not Equals: a != b
Less than: a < b
Less than or equal to: a <= b
Greater than: a > b
Greater than or equal to: a >= b
Conditional Statements
a = 400
b = 500
if b > a:
print("b is greater than a")
else:
print("a is greater than b")
Conditional Statements
a = 400
b = 500
if b > a:
print("b is greater than a")
elif a == b:
print("a and b are equal")
else:
print("a is greater than b")
Day 2- Tasks
6. You have marks of four subjects. Calculate the percentage of
marks.
7. Take input of temperature in celsius scale. Convert Celsius scale
to Fahrenheit scale.You can take help from slides.
8. Calculate salary of an employee based on hours spend. You can
take help from slides.
9. Take input from user for number a. Check whether the number is
an even/odd number.
Hint: use % modulus operator to get the remainder. i.e. in
statement c=a%2, a%2 assigned the remainder value to c.
10. Take two numbers from user as input. check the greater
number is divisor of four or not?