Question

In python, Write a function that will ask user to enter a number and find if...

In python,

Write a function that will ask user to enter a number and find if it is odd or even.

Example run:

Please enter a number: 5

5 is an odd number

Please enter a number: 10

10 is an even number

0 0
Add a comment Improve this question Transcribed image text
Answer #1
def even_or_odd():
    n = int(input('Please enter a number: '))
    if n % 2 == 0:
        print(str(n) + ' is an even number')
    else:
        print(str(n) + ' is an odd number')


even_or_odd()

Please enter a number: 10 is an even number Process finished with exit code 0

Add a comment
Know the answer?
Add Answer to:
In python, Write a function that will ask user to enter a number and find if...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write an assembly code that ask the user to enter a number and put it in...

    Write an assembly code that ask the user to enter a number and put it in variable called ''num1'' and check if number in variable num1 , is positive even or positive odd or negative even or negative odd If number is positive even , put the number into variable called '' positiveEven '' and show a message '' the number is positive even'' If number is negative even , put the number into variable called '' negativeEven'' and show...

  • Write a code using loop and flag function in python jupitior notebook: Ask the user for...

    Write a code using loop and flag function in python jupitior notebook: Ask the user for the number of items they bought. Also ask the price of each item they bought and quantity purchased. Display the total amount they owe. Ask the user for a number n. Calculate 1+2+3+….+n. Ask the user for a number n. Calculate 1*2*3*…*n. Ask the user for number of rows (r) and columns (c). Print * for r rows and c columns. Ask the user...

  • Write a python program that does the following. a. It asks the user to enter a...

    Write a python program that does the following. a. It asks the user to enter a 5-digit integer value, n. b. The program reads a value entered by the user. If the value is not in the right range, the program should terminate. c. The program calculates and stores the 5 individual digits of n. d. The program outputs a “bar code” made of 5 lines of stars that represent the digits of the number n. For example, the following...

  • IN PYTHON write a program that asks the user to enter 10 numbers and store them...

    IN PYTHON write a program that asks the user to enter 10 numbers and store them in the list and then find the followings: • Maximum • Minimum prime numbers in the list • even numbers in the list • odd numbers in the list.

  • please solve using python thank you! Write a program which prompts the user to enter a...

    please solve using python thank you! Write a program which prompts the user to enter a number of rows, and prints a hollow square star pattern with 2 diagonals. Note: you can assume that the integer will always be > 1 and will be an odd number. For example: Input Result 5 Enter number of rows: 5 ***** ** ** * * * ** ** ***** 9 Enter number of rows: 9 ** ** ** * * * * *...

  • Question 4 (3 mark) : Write a Java program to ask the user to input an...

    Question 4 (3 mark) : Write a Java program to ask the user to input an integer number from the keyboard. The output should indicate whether it is positive, zero, or negative, an even number or an odd number. REQUIREMENTS • Your code should ask user to input an integer number, then decide its sign and parity based on this input. • Your code should use if-else statement. Your code must work exactly as the specification and the output should...

  • Problem 1 Write a Python program to do the following: (A) Ask the user to enter...

    Problem 1 Write a Python program to do the following: (A) Ask the user to enter as many integers from 1 to 10 as he/she wants. Store the integers entered by the user in a list. Every time after the user has entered an integer, use a yes/no type question to ask whether he/she wants to enter another one. (B) Display the list. (C) Calculate and display the average of the integers in the list. (D) If the average is...

  • Write a program to print the hollow diamond of stars (*), ask the user to enter...

    Write a program to print the hollow diamond of stars (*), ask the user to enter an odd number as the height. For example, if user enters height as 7, output will look like: Y*

  • Example 3: Draw a flowchart that performs the following: Ask a user to enter a number....

    Example 3: Draw a flowchart that performs the following: Ask a user to enter a number. If the number is between 0 and 10, write the word blue. If the number is between 10 and 20, write the word red. if the number is between 20 and 30, write the word green. If it is any other number, write that it is not a correct color option. Example 4: Draw a flowchart to print all multiples of 5 between 1...

  • write in python idle Write full program that asks the user to enter his/her name then...

    write in python idle Write full program that asks the user to enter his/her name then repeatedly ask to enter the temperature in Fahrenheit and convert it to Celsius, the program should then prompt the user if he/she wants to continue or exit the program. The formula for conversion is: °C = (°F - 32) x 5/9 The program should use a function for the conversion. An Example of a sample run should appear on the screen like the text...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT