Question

Using Python and the command of for loop and range, while loop, if_elif_else , 1. In...

Using Python and the command of for loop and range, while loop, if_elif_else ,

1. In this problem you must design an algorithm to identify whether a number is
multiple of 3,  5 and 7 . That is, the algorithm receives a number and must tell the user if the number is:

(make a program)

• only multiple of 3
• only multiple of 5
• only multiple of 7
• only multiple of 3 and 5
• only multiple of 3 and 7
• only multiple of 5 and 7
• multiple of 3, 5 and 7
• is not a multiple of 3, 5, or 7

Please include a desktop test with the numbers 48959,48960 y 48961.

Homework Answers

Answer #1

/*If you have any query do comment in the comment section else like the solution*/

num = int(input())
if num%3 == 0 and num%5 == 0 and num%7 == 0:
    print("{} is divsible by 3, 5 and 7".format(num))
elif num%3 == 0 and num%5 == 0:
    print("{} is divsible by 3 and 5".format(num))
elif num%3 == 0 and num%7 == 0:
    print("{} is divsible by 3 and 7".format(num))
elif num%7 == 0 and num%5 == 0:
    print("{} is divsible by 5 and 7".format(num))
elif num%3 == 0:
    print("{} is divsible by 3".format(num))
elif num % 5 == 0:
    print("{} is divsible by 5".format(num))
elif num % 7 == 0:
    print("{} is divsible by 7".format(num))
else:
    print("{} is not divisible by 3, 5, or 7".format(num))

Output:

Know the answer?
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
Similar Questions
On Python Ask the user to input a min and a max value for a range...
On Python Ask the user to input a min and a max value for a range of numbers. Then use range(min, max) to: a) Loop through the range specified by the user and find all the numbers that are divisible by 3 and print them. b) Loop through the range and find only the first multiple of 3 and print it.
Uses a while loop to print the numbers from 3 - 19. Uses a do-while loop...
Uses a while loop to print the numbers from 3 - 19. Uses a do-while loop to print the numbers from 42 - 56. Uses a for loop to print the numbers from 87 - 95. Asks the user for 2 numbers. Uses a loop to print all numbers between the given numbers, inclusive. Note: Consider that your user's second number can be lower! (see example below) Note: Also consider that your user might give you two of the same...
Using a for loop and range command, print the sequence of numbers from 1 to 20...
Using a for loop and range command, print the sequence of numbers from 1 to 20 (skipping two numbers for each element); that is, your code should print out the numbers 1,4, 7, 10, … (max should not exceed 20). Use x as the variable name
USING PYTHON do all the he problems using while loop , continue and break 1-This problem...
USING PYTHON do all the he problems using while loop , continue and break 1-This problem provides practice using a while True loop.write a function named twoWords that gets and returns two words from a user. The first word is of a specified length, and the second word begins with a specified letter.The function twoWords takes two parameters: an integer, length, that is the length of the first word and a character, firstLetter, that is the first letter of the...
8.36 Lab 8a: Count by 3 Introduction For this lab, you will use a while loop...
8.36 Lab 8a: Count by 3 Introduction For this lab, you will use a while loop to complete the task. A while loop has this basic structure: /* variable initializations */ while (/*stop condition*/){ /* statements to be performed multiple times */ /* make sure the variable that the stop condition relies on is changed inside the loop. */ } Despite the structure of the while loop being different than that of a for loop, the concept behind it is...
An integer 'n' greater than 1 is prime if its only positive divisor is 1 or...
An integer 'n' greater than 1 is prime if its only positive divisor is 1 or itself. For example, 2, 3, 5, and 7 are prime numbers, but 4, 6, 8, and 9 are not. Write a python program that defines a function isPrime (number) with the following header: def isPrime (number): that checks whether a number is prime or not. Use that function in your main program to count the number of prime numbers that are less than 5000....
Python Programming questions, Multiple Choice Questions: 5) MCQ What function call will generate a random number...
Python Programming questions, Multiple Choice Questions: 5) MCQ What function call will generate a random number in the range of 1 through 6 using the random module? a. random.randnum(1, 6) b. random.randint(range(1-6)) c. random.randint(1, 6) d. random.random(1, 6) 6) MCQ In a conditional iteration loop, such as a while loop, what is a sentinel value? a. A sentinel value is a user-provided input value that proceeds to the next loop. b. A sentinel value is a user-provided input value that...
1) Write a java programming using a while loop where you will add numbers and when...
1) Write a java programming using a while loop where you will add numbers and when you press number 0 it will add all your numbers and display the results. Use Scanner object. Steps: 1) Declare variables integer called sum which is equal to zero   2) Declare Scanner object   3) Declare while condition where is true   4) Inside of that condition prompt the user to enter the numbers   5) Declare variable integer called number and input the number statement   6)...
Python code only! (Do not include breaks or continue functions) Write a program that asks the...
Python code only! (Do not include breaks or continue functions) Write a program that asks the user to enter the amount that they budgeted for the month. A loop should then prompt the user to enter their expenses, one at a time and to enter 0 to quit. When the loop finishes, the program should display the the amount of budget left. (a negative number indicates the user is over budget and a positive number indicates the user is under...
Write a program that finds and prints all of the prime numbers between 3 and X...
Write a program that finds and prints all of the prime numbers between 3 and X (X is input from the user). A prime number is a number such that 1 and itself are the only numbers that evenly divide it (for example, 3, 5, 7, 11, 13, 17, …). One way to solve this problem is to use a doubly nested loop (a loop inside another loop). The outer loop can iterate from 3 to N while the inner...