To write a Python program to check whether the given number is even or odd using if...else statements.
- Get an input from the user.
- Convert the input to an integer and store it in a variable
a. - Use the modulo operator
%to check ifa % 2 == 0.- If true, print
"EVEN". - Else, print
"ODD".
- If true, print
- End the program.
''' a=int(input()) if a%2==0: print('EVEN') else: print("ODD") '''
The python code for checking odd or even is suucessfully executed
To write a Python program that evaluates and prints the results of boolean and arithmetic expressions involving True and False.
- Set variable
ato the result of the expression0 == True. - Set variable
bto the result of the expressionFalse == False. - Set variable
cto the result of the expressionTrue + True. - Set variable
dto the result of the expressionFalse + 9. - Print the value of
awith the label "a is". - Print the value of
bwith the label "b is". - Print the value of
cwith the label "c:". - Print the value of
dwith the label "d:".
''' a=1 b=1 c=1 d=0 a = (1 == True) b = (1 == False) c = True + 3 d = False + 7 print("a is",a) print("b is",b) print("c:",c) print("d:",d) '''
The python code for Boolean Expression is succesfully executed
To write a Python program that prints the characters 'T' and 'a' using character literals.
- Print the character
'T'. - Print the character
'a'.
''' print("T") print('a') '''
The python code for printing the character literals is successfully executed
To write a Python program that reads two integers, creates a complex number using them, and then prints the complex number along with its real and imaginary parts.
- Read an integer input from the user and assign it to the variable
a(real part). - Read another integer input from the user and assign it to the variable
b(imaginary part). - Create a complex number
xusing thecomplex(a, b)function. - Print the complex number
x. - Print the real part of
xusingx.real. - Print the imaginary part of
xusingx.imag.
''' a=complex(input()) b=complex(input()) print("A is",a) print("B is",b) print("Sum is",a+b) '''
The python program for complex numbers is successfully executed
To write a Python program to read a string from the user and then print it.
- Assign a variable named
men_stepped_on_the_moon. - Use
input()to read a string from the user and store it in the variable. - Print the value stored in the variable.
''' men_stepped_on_the_moon=input() print(men_stepped_on_the_moon) '''
The python program for reading and printing strings is successfully executed




