Python_Operators_Practice_Answers
# Arithematic operators
#Ex: Write a Program to read the two numbers, 1. print the sum 2. Assign the sum into different varaible 'total' and dispaly the value.
#Ex: Write a Program to read the two numbers, 1. print the difference 2. Assign the difference into different varaible 'difference' and dispaly the value.
#Ex: Write a Program to read the two numbers 1. print the multiplication 2. Assign the product into different varaible 'product' and dispaly the value.
#Ex: Write a Program to read the two numbers 1. print the division 2. assign the varaible 'quotient' and 'nearest remainder' and 'nearest remainder' and dispaly the value.
#Ex: Write a Program to read the two numbers 1. print the power of a given variable 2. and Assign the power value into different varaible 'power' dispaly the value.
[Revision]
#Ex: Write a Program to read the two numbers and apply all the 5 arithmetic operations. Print the operation values directly using print statement. Assign each arithmetic operation value in to variable and display the variable value.
# LOGICAL OPERATOR
#Ex: Write a Program to read the two numbers,
# 1. print the result as true if two values are EQUAL and also assign the result into different varaible and dispaly the value.
#2. print the result as true if two values are NOT EQUAL 2. Assign the result into different varaible and dispaly the value.
#3. print the result as true if first number is GREATER THAN second number 2. Assign the result into different varaible and dispaly the value.
#4.print the result as true if first number is GREATER THAN or EQUAL second number 2. Assign the result into different varaible and dispaly the value.
#5. print the result as true if first number is LESS THAN second number 2. Assign the result into different varaible and dispaly the value.
#6. print the result as true if first number is LESS THAN or EQUAL second number 2. Assign the result into different varaible and dispaly the value.
___________________________________________________________________________________# Arithematic operators
first_num = 5
second_num = 3
print(first_num + second_num)
first_num = 5
second_num = 3
print(first_num - second_num)
first_num = 5
second_num = 3
print(first_num * second_num)
first_num = 5
second_num = 2
print(first_num % second_num)
first_num = 15
second_num = 2
print(first_num // second_num)
# the floor division // rounds the result down to the nearest whole number
first_num = 15
second_num = 2
print(first_num / second_num)
first_num = 2
second_num = 5
print(first_num ** second_num) # same as 2*2*2*2*2#Ex: Write a Program to read the two numbers, 1. print the sum 2. Assign the sum into different varaible 'total' and dispaly the value.
first_num = int(input("Enter the first operand:"))
second_num = int(input("Enter the second operand:"))
print(first_num + second_num)
sum = first_num + second_num
print(sum)
#Ex: Write a Program to read the two numbers, 1. print the difference 2. Assign the difference into different varaible 'difference' and dispaly the value.
first_num = int(input("Enter the first operand:"))
second_num = int(input("Enter the second operand:"))
print(first_num - second_num)
difference = first_num * second_num
print(difference)
#Ex: Write a Program to read the two numbers 1. print the multiplication 2. Assign the product into different varaible 'product' and dispaly the value.
first_num = int(input("Enter the first operand:"))
second_num = int(input("Enter the second operand:"))
print(first_num * second_num)
product = first_num * second_num
print(product)
#Ex: Write a Program to read the two numbers 1. print the division 2. assign the varaible 'quotient' and 'nearest remainder' and 'nearest remainder' and dispaly the value.
first_num = int(input("Enter the first operand:"))
second_num = int(input("Enter the second operand:"))
print(first_num - second_num)
quotient1 = first_num / second_num
print(quotient1)
quotient2 = first_num // second_num
# the floor division // rounds the result down to the nearest whole number
print(quotient2)
rem = first_num % second_num
print(rem)
#Ex: Write a Program to read the two numbers 1. print the power of a given variable 2. and Assign the power value into different varaible 'power' dispaly the value.
first_num = 2
second_num = 5
print(first_num ** second_num) # same as 2*2*2*2*2
pwer = first_num ** second_num
print(pwer)
#Ex: Write a Program to read the two numbers and apply all the 5 arithmetic operations.
# Print the operation values directly using print statement
# Assign each arithmetic operation value in to variable and display the variable value.
first_num = int(input("Enter the first operand:"))
second_num = int(input("Enter the second operand:"))
print(first_num - second_num)
print(sum)
sum = first_num * second_num
print(sum)
print(first_num - second_num)
difference = first_num * second_num
print(difference)
print(first_num * second_num)
product = first_num * second_num
print(product)
quotient1 = first_num / second_num
print(quotient1)
quotient2 = first_num // second_num
# the floor division // rounds the result down to the nearest whole number
print(quotient2)
rem = first_num % second_num
print(rem)
print(first_num ** second_num) # same as 2*2*2*2*2
pwer = first_num ** second_num
print(pwer)____________________________________________________________________________________________#Ex: Write a Program to read the two numbers,
# 1. print the result as true if two values are EQUAL and also assign the result into different varaible and dispaly the value.
#2. print the result as true if two values are NOT EQUAL 2. Assign the result into different varaible and dispaly the value.
#3. print the result as true if first number is GREATER THAN second number 2. Assign the result into different varaible and dispaly the value.
#4.print the result as true if first number is GREATER THAN or EQUAL second number 2. Assign the result into different varaible and dispaly the value.
#5. print the result as true if first number is LESS THAN second number 2. Assign the result into different varaible and dispaly the value.
#6. print the result as true if first number is LESS THAN or EQUAL second number 2. Assign the result into different varaible and dispaly the value.
first_number = 5
second_number = 3
print(first_number == second_number)
vars_equal = (first_number == second_number)
print(vars_equal)
# returns False because 5 is not equal to 3
first_number = 5
second_number = 3
print(first_number != second_number)
vars_not_equal=(first_number != second_number)
# returns True because 5 is not equal to 3
print(vars_not_equal)
first_number = 5
second_number = 3
print(first_number > second_number)
# returns True because 5 is greater than 3
grt_var = (first_number > second_number)
print(grt_var)
first_number = 5
second_number = 3
print(first_number < second_number)
# returns False because 5 is not less than 3
lss_var = (first_number < second_number)
print(lss_var)
first_number = 5
second_number = 3
print(first_number >= second_number)
# returns True because five is greater, or equal, to 3
grt_eql = (first_number >= second_number)
print(grt_eql)
first_number = 5
second_number = 3
print(first_number <= second_number)
# returns False because 5 is neither less than or equal to 3
lss_eql = (first_number <= second_number)
print(lss_eql)
Comments
Post a Comment