Read a number from the user. Check whether it is odd or even using lambda function and print the output as either ODD or EVEN. Sample Input5Sample OutputODD
Question
Read a number from the user. Check whether it is odd or even using lambda function and print the output as either ODD or EVEN. Sample Input5Sample OutputODD
Solution
Sure, here are the steps to solve the problem:
- Read a number from the user.
- Define a lambda function to check whether the number is odd or even. The lambda function can be written as:
is_even = lambda num: num % 2 == 0 - Use the lambda function to check whether the number is even or odd. You can do this by calling the lambda function with the input number as an argument.
is_even_result = is_even(number) - Print the output based on the result of the lambda function. If the result is True, print "EVEN". Otherwise, print "ODD".
if is_even_result: print("EVEN") else: print("ODD")
By following these steps, you can determine whether a given number is odd or even using a lambda function and print the output accordingly.
Similar Questions
Read a number from the user. Check whether it is zero or non-zero using the lambda function and print the output as either ZERO or NON-ZERO. Sample Input5Sample OutputNON-ZERO
Write a program to print only the even numbers till given NInput FormatA single integer 'N'Output FormatDisplay all the even numbers between 0 and NSample Input10Sample Output0 2 4 6 8 10
Write a program to print the odd values in the given rangeInput FormatTwo space separated integers - 'start' and 'end'Output FormatDisplay all the odd numbers between 'start' and 'end'Sample Input10 20Sample Output11 13 15 17 19
Complete the function count_odd_even() , which receives number of elements and array as input. Function should count number of even numbers and odd numbers in the array and print it.Input Format:No Need to read any input, as it is predefined.Output Format:Print the count of odd and even as: Odd = ODD_COUNTEven = EVEN_COUNTConstraints:1<=size<=10^9 1<=arr[ind]<=10^15Sample Input 1:1047 41 87 88 95 46 35 66 63 93Sample Output 1:Odd = 7Even = 3Sample Input 2:81 2 3 4 5 6 7 8Sample Output 2:Odd = 4Even = 4
ingle File Programming QuestionProblem StatementAmil, a curious coder, has a distinctive approach to handling numerical input. Write a program to get an integer from the user. If the number is even, the system employs a goto statement to a label indicating an affirmative response. Otherwise, another goto statement conveys a negative response.Input format :The input consists of a single integer n.Output format :The output displays one of the following:If n is an even number, it displays "You entered an even number."If n is an odd number, it displays "You entered an odd number."Refer to the sample output for the formatting specifications.Code constraints :In the given scenario, the test cases fall under the following constraints:1 ≤ n ≤ 100Sample test cases :Input 1 :1Output 1 :You entered an odd number.Input 2 :100Output 2 :You entered an even number.Input 3 :67Output 3 :You entered an odd number.Note :The program will be evaluated only after the “Submit Code” is clicked.Extra spaces and new line characters in the program output will result in the failure of the test case.
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.