Question

In: Computer Science

Can you please write this in python thank you. Consider 'x' being a number chosen by...

Can you please write this in python thank you.

Consider 'x' being a number chosen by a user. Using python conditional statements, write a code that:

  • prints "x is a multiple of 3 and 5" if x is dividable by both numbers 3 and 5
  • prints "x is a multiple of 7 or 11" if x is dividable be either numbers 7 or 11.

Solutions

Expert Solution


x=int(input("Enter a number: "))
if(x%3==0 and x%5==0):
    print(x,"is a multiple of 3 and 5")
elif(x%7==0 or x%11==0):
    print(x,"is a multiple of 7 or 11")
else:
    #please undo the below comment to get a output which doesnt comes under the above conditions
    #print("Not a multiple of 3,5,7,11")
    print("")

Output:

NOTE: In the above question, there is no print statement given for the number that doesnt fall under either of the conditions. so comments are given if you want an answer, please remove comments from ' else' statement to get output for such numbers.


Related Solutions

can you paraphrase this please!! thank you! "The students have fixed number of hours in a...
can you paraphrase this please!! thank you! "The students have fixed number of hours in a week to choose between studying and working, it is completely incorrect in saying that whether it is the study that causes work or work causes study. It is generally assumed that students always choose total hours as a mix of studying and working depending on their rational behavior. This would help them maximizing their utility subject to the constraint of limited fixed hours in...
Please write a basic function using Python. Please comment all steps. Thank you! Experimentally determined molecular...
Please write a basic function using Python. Please comment all steps. Thank you! Experimentally determined molecular structures are stored in the Protein Data Bank. Protein Data Bank format is a standard for files containing atomic coordinates which are stored in the “ATOM” record. Write a Python function to extract x coordinate of each atom for a given PDB file. Test your function with the provided “1a3d.pdb” file as the example. Also, give a good thought what would be the proper...
Can you please write this in python and comment as well so I can understand what...
Can you please write this in python and comment as well so I can understand what yo are doing. Thank you. 1)Loop through list A, at each iteration, show the square root result of that element. Add proper text to your print function. A = [-4, 1, -16, 36, -49, 64, -128] 2)Create a counter variable, name it i and initialize it to 0. Using a for loop, count how many numbers are divisible by 3 in range of 1...
Given a string, such as x = ‘itm330’, write a Python program to count the number...
Given a string, such as x = ‘itm330’, write a Python program to count the number of digits and the number of letters in it. For example, in ‘itm330’, there are 3 letters and 3 digits. Hint: Very similar to page 11 on the slides. To check if a character c is a digit, use c.isdigit(). If c is a digit, c.isdigit() will be a True.
USING PYTHON. Thank you in advance Write a program that allows the user to enter a...
USING PYTHON. Thank you in advance Write a program that allows the user to enter a series of string values into a list. When the user enters the string ‘done’, stop prompting for values. Once the user is done entering strings, create a new list containing a palindrome by combining the original list with the content of the original list in a reversed order. Sample interaction: Enter string: My Enter string: name Enter string: is Enter string: Sue Enter string:...
using java For this assignment, you will write a program that guesses a number chosen by...
using java For this assignment, you will write a program that guesses a number chosen by your user. Your program will prompt the user to pick a number from 1 to 10. The program asks the user yes or no questions, and the guesses the user’s number. When the program starts up, it outputs a prompt asking the user to choose a number from 1 to 10. It then proceeds to ask a series of questions requiring a yes or...
Python program. Write a python program that can convert any radix-d (arbitrary base) number to the...
Python program. Write a python program that can convert any radix-d (arbitrary base) number to the equivalent radix-e (another arbitrary base) number. Where e and d are members in [2, 16]. Remember, base 16 needs to be calculated as hexadecimal. So, if radix-d is input as a hexadecimal number, it needs to convert and output to desired base. Conversely, if base 16 is the desired output, then the output needs to show a hexadecimal number. Hints: The easiest approach is...
using python: Given an arbitrary whole number, please write an if statement to output if it...
using python: Given an arbitrary whole number, please write an if statement to output if it is an even number or an odd number
PLEASE USE PYTHON THANK YOU In the game of Lucky Sevens, the player rolls a pair...
PLEASE USE PYTHON THANK YOU In the game of Lucky Sevens, the player rolls a pair of dice. If the dots add up to 7, the player wins $4; otherwise, the player loses $1. Suppose that, to entice the gullible, a casino tells players that there are many ways to win: (1, 6), (2, 5), and soon. A little mathematical analysis reveals that there are not enough ways to win to make the game worthwhile; however, because many people's eyes...
Please do this code with python. Thank you! struct Node {     int data;     struct...
Please do this code with python. Thank you! struct Node {     int data;     struct Node* left;     struct Node* right; }; // Node creation struct Node* newNode(int data) {     struct Node* nn         = new Node;     nn->data = data;     nn->left = NULL;     nn->right = NULL;     return nn; } // Function to insert data in BST struct Node* insert(struct Node* root, int data) {   if (root == NULL)         return newNode(data);     else {...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT