Question

In: Computer Science

using python 3 2. Write a python program that finds the numbers that are divisible by...

using python 3

2. Write a python program that finds the numbers that are divisible by both 2 and 7 but not 70, or that are divisible by 57 between 1 and 1000.

3. Write a function called YesNo that receives as input each of the numbers between 1 and 1000 and returns True if the number is divisible by both 2 and 7 but not 70, or it is divisible by 57. Otherwise it returns False.

4. In your main Python program write a for loop that counts from 1 to 1000 and calls this YesNo function inside the for loop and will print "The number xx is divisible by both 2 and 7 but not 70, or that are divisible by 57" if the YesNo function returns True. Otherwise it prints nothing. Note the print statement also prints the number where the xx is above.

Solutions

Expert Solution

def YesNo(n):

#checking divisable by 2 and 7 not by 70 or by 57

  return (n%2==0 and n%7==0 and n%70!=0) or n%57==0

if __name__ == '__main__':

#iterating from 1-1000

for x in range(1,1001):

#if YesNo returns true than print

   if YesNo(x):

     print("he number ",x," is divisible by both 2 and 7 but not 70, or that are divisible by 57")

Note : Please comment below if you have concerns. I am here to help you

If you like my answer please rate and help me it is very Imp for me


Related Solutions

using python 3 2. Write a python program that finds the numbers that are divisible by...
using python 3 2. Write a python program that finds the numbers that are divisible by both 2 and 7 but not 70, or that are divisible by 57 between 1 and 1000. 3. Write a function called YesNo that receives as input each of the numbers between 1 and 1000 and returns True if the number is divisible by both 2 and 7 but not 70, or it is divisible by 57. Otherwise it returns False. 4. In your...
Using Python, write a program that finds a root of function f(x) = x^2-4x+3 on interval...
Using Python, write a program that finds a root of function f(x) = x^2-4x+3 on interval [2,5] using bisection search method. Recall that r is a root of a function if f(r) = 0. Output the number of iterations it took your algorithm to find a root.
Write a program that counts how many Fibonacci numbers are divisible by 3 and smaller than...
Write a program that counts how many Fibonacci numbers are divisible by 3 and smaller than 1000. The program prints the resulting number. You may only use while loops. Use python language
Write a program that counts how many Fibonacci numbers are divisible by 3 and smaller than...
Write a program that counts how many Fibonacci numbers are divisible by 3 and smaller than 1000. The program prints the resulting number. You may only use while loops. Use python language
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...
Write a Python program that has a list of 5 numbers [2, 3, 4, 5, 6)....
Write a Python program that has a list of 5 numbers [2, 3, 4, 5, 6). Print the first 3 elements from the list using slice expression. a. Extend this program in a manner that the elements in the list are changed to (6, 9, 12, 15, 18) that means each element is times 3 of the previous value. b. Extend your program to display the min and max value in the list.
JAVA Write a program to sum the numbers from 1 to 100 that are divisible by...
JAVA Write a program to sum the numbers from 1 to 100 that are divisible by 7, and compute the average of those numbers, print both the sum and the average with appropriate messages to the screen. Run the program. Capture the console output. Put the program code and console output at the end of your text file,
Using the Python program: a/ Write a program that adds all numbers from 1 to 100...
Using the Python program: a/ Write a program that adds all numbers from 1 to 100 to a list (in order). Then remove the multiples of 3 from the list. Print the remaining values. b/ Write a program that initializes a list with ten random integers from 1 to 100. Then remove the multiples of 3 and 5 from the list. Print the remaining values. Please show your work and explain. Thanks
Java Write a program that displays all the numbers from 100 to 200 that are divisible...
Java Write a program that displays all the numbers from 100 to 200 that are divisible by 5 or 6, but not both Make sure all instructions and outputs for the user are explicit
Write a C++ program that displays the numbers between 1000 and 9999, which are divisible by...
Write a C++ program that displays the numbers between 1000 and 9999, which are divisible by sum of the digits in them. For example, 2924 is divisible by (2+9+2+4 = 17). Your program should display all these possible numbers in the given range, and each number should be separated from the other by a space.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT