Question

Consider 'y' being a number chosen by a user. Using python conditional statements: If y is...

Consider 'y' being a number chosen by a user.

Using python conditional statements:

  • If y is a multiple of 7, print "y is dividable by 7"
  • Otherwise, print "y divided by 7 has a remainder of R".

Note that you have to show the value of y and R in your printed output not the alphabetic y and R!

Homework Answers

Answer #1

code:

# Reading input from user
y = int(input("Choose a number: "))

# modulus operator(%) is used to find the remainder
# If the remainder is 0 when we divide the number with 7 then it is multiple of 7
if y%7 == 0:
print(str(y)+" is dividable by 7")
else:
R = y%7
print(str(y)+" divided by 7 has a remainder of "+str(R))

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
create a basic python program that converts binary to number (using if statements etc) Asking user...
create a basic python program that converts binary to number (using if statements etc) Asking user for input of binary number converting/calculating printing
By using Python code answer the following parts: A) Write a program to ask the user...
By using Python code answer the following parts: A) Write a program to ask the user to input their name and then output the type and length of the input. B) Write a program to output the last 11 letters of 'Introduction to Indiana'. C) Write a program to output the 3rd to the 11th letters of 'Introduction to Indiana'. D) Write a program to ask the user to input a float number and output the rounded value of it...
Using R Programming language write a program to Check Prime Number (entered by the user) using...
Using R Programming language write a program to Check Prime Number (entered by the user) using control statements. Note: a prime number is an integer number greater than 1 whose only factors are 1 and itself. For example: 2, 3, 5, 7, 11, 13, 17.19 etc. USING R PROGRAMMING
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...
python: write a two card poker game, the user and the computer will get two cards,...
python: write a two card poker game, the user and the computer will get two cards, cards are an integer value between 2-14 and are printed out as 2,3,4,5,6,7,8,9,10,J,Q,K,A. the winner is when: if both players have a pair then the pair with the highest numerical value wins, if only one player has a pair, then the pair wins, if neither the players has a pair, then the player with the highest card wins, if both players highest card is...
Please answer this using def (functions) in python 3 with a single print statement under #main....
Please answer this using def (functions) in python 3 with a single print statement under #main. Is this possible to do in one print as output? User specifies the number of books ordered, and if the order is online, or not. You can collect the second input by asking the user to enter 1 for online, and 0 for offline. You can assume that the user will enter 1 or 0 as directed. Unit price for a book is 15$....
***Python Hailstones, also known as the Collatz sequence, are a mathematical curiosity. For any number in...
***Python Hailstones, also known as the Collatz sequence, are a mathematical curiosity. For any number in the sequence, the next number in the sequence is determined by two simple rules: If the current number n is odd, the next number in the sequence is equal to 3 * n + 1 If the current number n is even instead, the next number in the sequence is equal to one half of n (i.e., n divided by 2) We repeat this...
Please do it in Python Write the simplest program that will demonstrate iteration vs recursion using...
Please do it in Python Write the simplest program that will demonstrate iteration vs recursion using the following guidelines - Write two primary helper functions - one iterative (IsArrayPrimeIter) and one recursive (IsArrayPrimeRecur) - each of which Take the array and its size as input params and return a bool. Print out a message "Entering <function_name>" as the first statement of each function. Perform the code to test whether every element of the array is a Prime number. Print out...
Python: Write a program that prompts the user to enter a positive integer value, and compute...
Python: Write a program that prompts the user to enter a positive integer value, and compute the following sequence: • If the value is even, halve it. • If it's odd, multiply by 3 and add 1. • Repeat this process until the value is 1, printing out each value. • Then print out how many of these operations you performed. If the input value is less than 1, print a message containing the word Error and exit the program....
APPLIED STATISTICS 2 USE R CODE ! SHOW R CODE! Write a function to calculate the...
APPLIED STATISTICS 2 USE R CODE ! SHOW R CODE! Write a function to calculate the sum of cubes from 1 to n, but skip the multiple of 5. Say, if n=10, the result is 1^3+2^3+3^3+4^3+6^3+7^3+8^3+9^3. The input is the value of n, the output is the summation. (you need if statement to check whether a number is a multiple of 5.In R, a%%b is the remainder for a divided by b. So, we have 10%%5=0) APPLIED STATISTICS 2 USE...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT