Question

In: Computer Science

Python # Write a program that examines three variables—x, y, and z # and prints the...

Python
# Write a program that examines three variables—x, y, and z
# and prints the largest odd number among them.
# If none of them are odd, it should print a message to that effect.

n = input('Enter the 1st Integer x: ')
x = int(n)
n = input('Enter the 2nd Integer y: ')
y = int(n)
n = input('Enter the 3rd Integer z: ')
z = int(n)

if x % 2 == 0 and y % 2 == 0 and z % 2 == 0:
print ("None of them are odd")

if x % 2 == 1 and (x >= y or y % 2 == 0) and (x >= z or z % 2 == 0):
print (x,'- x is largest')

if y % 2 == 1 and (y >= x or x % 2 == 0) and (y >= z or z % 2 == 0):
print (y,'- y is largest')

if z % 2 == 1 and (z >= x or x % 2 == 0) and (z >= y or y % 2 == 0):
print (z,'- z is largest')
  

(a) Come up with the natural partition and test case for the above program.

Solutions

Expert Solution

n = input('Enter the 1st Integer x: ')
x = int(n)
n = input('Enter the 2nd Integer y: ')
y = int(n)
n = input('Enter the 3rd Integer z: ')
z = int(n)

if x % 2 == 0 and y % 2 == 0 and z % 2 == 0:
print ("None of them are odd")

if x % 2 == 1 and (x >= y or y % 2 == 0) and (x >= z or z % 2 == 0):
print (x,'- x is largest')

if y % 2 == 1 and (y >= x or x % 2 == 0) and (y >= z or z % 2 == 0):
print (y,'- y is largest')

if z % 2 == 1 and (z >= x or x % 2 == 0) and (z >= y or y % 2 == 0):
print (z,'- z is largest')

beaware of indentation

try to type the code


Related Solutions

1) Generate a data set with three variables (X, Y and Z). X and Y have...
1) Generate a data set with three variables (X, Y and Z). X and Y have 10 observations for each (N=10), and Z has 13 observations (N=13). Each observation should have two digits (such as “83” or “8.3”). 2) Draw a stem-and-leaf display for variable Z only and draw a box plot display for variable Z after specifying the 5 numbers (UEX, LEX, FU, FL, MD). 3) Calculate the mean and standard deviation for variable X 4) Calculate the mean...
If X, Y and Z are three arbitrary vectors, prove these identities: a. (X×Y).Z = X.(Y×Z)...
If X, Y and Z are three arbitrary vectors, prove these identities: a. (X×Y).Z = X.(Y×Z) b. X×(Y×Z) = (X.Z)Y – (X.Y)Z c. X.(Y×Z) = -Y.(X×Z)
The joint density function for random variables X, Y, and Z is f(x, y, z)= Cxyz  if...
The joint density function for random variables X, Y, and Z is f(x, y, z)= Cxyz  if 0 ≤ x ≤ 1, 0 ≤ y ≤ 2, 0 ≤ z ≤ 2, and f(x, y, z) = 0 otherwise. (a) Find the value of the constant C. (b) Find P(X ≤ 1, Y ≤ 1, Z ≤ 1). (c) Find P(X + Y + Z ≤ 1).
python Write a program that prints your name 100 times to the screen. Write a function...
python Write a program that prints your name 100 times to the screen. Write a function that takes a string s and an integer n as parameters and prints the string s a total of n times (once per line). Write a for loop that prints all the integers from 3141 to 5926, skipping every other one. Write a for loop that prints every 5th integer from 5926 down to 3141. Write a program (using a for loop) to print...
Write a program for Sense HAT (or the emulator) to map X, Y, and Z acceleration...
Write a program for Sense HAT (or the emulator) to map X, Y, and Z acceleration (or orientation) values into R, G, and B color values on the LED matrix. That way, when you tilt the Sense HAT, the LED matrix will display different colors to simulate a paint mixer. When you write your program, please consider using delay to avoid the problem of changing color too fast to be perceived. Also, you want to make sure that you map...
In Python write a program that calculates and prints out bills of the city water company....
In Python write a program that calculates and prints out bills of the city water company. The water rates vary, depending on whether the bill is for home use, commercial use, or industrial use. A code of r means residential use, a code of c means commercial use, and a code of i means industrial use. Any other code should be treated as an error. The water rates are computed as follows:Three types of customers and their billing rates: Code...
Python Assume s is a string of numbers. Write a program that prints the longest substring...
Python Assume s is a string of numbers. Write a program that prints the longest substring of s in which the numbers occur in ascending order and compute the average of the numbers found. For example, if s = '561984235272145785310', then your program should print: Longest substring in numeric ascending order is: 14578 Average: 5 In the case of ties, print the first substring. For example, if s = '147279', then your program should print Longest substring in numeric ascending...
Text Wrap Problem Write a program in Python that takes an input string and prints it...
Text Wrap Problem Write a program in Python that takes an input string and prints it as multiple lines of text such that no line of text is greater than 13 characters and words are kept whole. For example, the first line of the Gettysburg address: Four score and seven years ago our fathers brought forth upon this continent a new nation, conceived in liberty and dedicated to the proposition that all men are created equal Becomes: Four score and...
Write a python program that can solve system of linear equations in three variables using input...
Write a python program that can solve system of linear equations in three variables using input function. Paste your program in a word document or notepad. Note that I am using pycharm. please use a not really complex codes, thanks
[x, y, and z are integer variables, which expressions are equivalent to each other?] a. (x==y...
[x, y, and z are integer variables, which expressions are equivalent to each other?] a. (x==y && x !=z) || (x!=y && x==z) b. (x==y || x==z) && (x!=y || x!=z) c. (x==y) != (x==z)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT