Python Programming Code For Practice
Python Programming Code For Practice
a = 7
b = 2
# addition
print ('Sum: ', a + b)
# subtraction
print ('Subtraction: ', a - b)
# multiplication
print ('Multiplication: ', a * b)
# division
print ('Division: ', a / b)
# floor division
print ('Floor Division: ', a // b)
# modulo
print ('Modulo: ', a % b)
# a to the power b
print ('Power: ', a ** b)
CODE 1:
t = turtle.Turtle()
def draw_triangle(side_length):
for i in range(0,3):
t.forward(side_length)
t.right(120)
draw_triangle(100)
PYTHON PRACTICAL CODES FOR FINAL TERM
celsius = 54
fahrenheit = (celsius * 1.8) + 32
print(str(celsius )+ " degree Celsius is equal to " + str(fahrenheit )+ " degree Fahrenheit.")
celsius = ((fahrenheit-32)*5)/9
print("Celcius= ",celsius)
PYTHON PRACTICAL CODES FOR FINAL TERM
CODE 7:
x = 35e3
y = 12E4
z = -87.7e100
print(type(x))
print(type(y))
print(type(z))
CODE 9:
Example
Test if a is greater than b, AND if c is greater than a:
a = 200
b = 33
c = 500
if a > b and c > a:
print("Both conditions are True")