Question

Having a difficult time with last practice problems in Python 3 # [ ] get input...

Having a difficult time with last practice problems in Python 3
# [ ] get input of 2 numbers and subtract the largest from the smallest (use an if statement to see which is larger)
# show the answer


# [ ] Divide a larger number by a smaller number and print the integer part of the result
# don't divide by zero! if a zero is input make the result zero
# [ ] cast the answer to an integer to cut off the decimals and print the result

0 0
Add a comment Improve this question Transcribed image text
Answer #1
n1 = int(input("Enter number1: "))
n2 = int(input("Enter number2: "))
if(n1 < n2):
    t = n1
    n1 = n2
    n2 = t
print("Subtraction result =",(n1-n2))

if(n2!=0):
    print("Division result =",(n1//n2))
else:
    print("Denominator is zero")

Enter number1: 6
Enter number2: 2
Subtraction result = 4
Division result = 3

Add a comment
Know the answer?
Add Answer to:
Having a difficult time with last practice problems in Python 3 # [ ] get input...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Swapping Values in python Summary In this lab, you complete a Python program that swaps values...

    Swapping Values in python Summary In this lab, you complete a Python program that swaps values stored in three variables and determines maximum and minimum values. The Python file provided for this lab contains the necessary input and output statements. You want to end up with the smallest value stored in the variable named first and the largest value stored in the variable named third. You need to write the statements that compare the values and swap them if appropriate....

  • IN PYTHON 1.Choose a positive integer 2. To get the next number in the sequence we...

    IN PYTHON 1.Choose a positive integer 2. To get the next number in the sequence we do the following: If the integer is odd, we multiply by 3 and add 1. If the integer is even, we divide by 2. It is hypothesized that the above sequence will always converge to the value of 1, regardless of any valid initial choice. This hypothesis is known as the Collatz Conjecture. For example, if we start at 5, the numbers generated by...

  • need help with python program The objectives of this lab assignment are as follows: . Input...

    need help with python program The objectives of this lab assignment are as follows: . Input data from user Perform several different calculations Implement conditional logic in loop • Implement logic in functions Output information to user Skills Required To properly complete this assignment, you will need to apply the following skills: . Read string input from the console and convert input to required numeric data-types Understand how to use the Python Modulo Operator Understand the if / elif /...

  • python program sample output Problem 3 (Taking User Input) Write a function called userGuess(n) that takes...

    python program sample output Problem 3 (Taking User Input) Write a function called userGuess(n) that takes an integer n as an argument. This function should display n to the user and prompt them to enter the number num that is the largest power of 2 less than or equal to n. Have your function return the user's input num (it will be used in the next problem) Problem 4 (Making a Game) Finally, create a main() function for your program....

  • I want this using while loop This using stringin python Use list or some thing in...

    I want this using while loop This using stringin python Use list or some thing in python Using list in python I want answer as soon as posdible E. Last Number time limit per test: 1 second memory limit per test: 256 megabytes input standard input output standard output You are given a sequence of positive integers aj, , 03, ... Print the last element of the sequence. Input The input consists of multiple lines. The i-th line contains a...

  • 1. program to use with number 1. 2. Comparing Python and Java Discussion Forum 14 days ago Use the Python...

    1. program to use with number 1. 2. Comparing Python and Java Discussion Forum 14 days ago Use the Python IDLE editor to create the source code for the "numberguess.py" pro- gram. This program is in the "Basic Python Pro- gramming" chapter in its "An Example Python Program: Guessing a Number" section. If you mistakenly create syntax errors, find and fix them. Run the program and test it with various values. Refer to the "numberguess.py Program document to see example...

  • Help needed related python ! Thanx 6. What makes the exclusive-or the most interesting of the...

    Help needed related python ! Thanx 6. What makes the exclusive-or the most interesting of the logic operations in Boolean algebra? (Hint: try them and see.) 7. The How Computers Work Part III video from Week 1 talks about assembly level abstraction. Why is it better than machine code? Why is the assembly level abstraction still not abstract enough? Give the 2300 year old algorithm by Euclid for finding the greatest common divisor which is: 8. 9. Get two positive...

  • You need not run Python programs on a computer in solving the following problems. Place your...

    You need not run Python programs on a computer in solving the following problems. Place your answers into separate "text" files using the names indicated on each problem. Please create your text files using the same text editor that you use for your .py files. Answer submitted in another file format such as .doc, .pages, .rtf, or.pdf will lose least one point per problem! [1] 3 points Use file math.txt What is the precise output from the following code? bar...

  • use python IDEL Please highlight the answer Problem 1 Errors and Exceptions. There are two main...

    use python IDEL Please highlight the answer Problem 1 Errors and Exceptions. There are two main types of errors: syntax errors and runtime errors. Syntax errors are detected by the Python interpreter before the program execution during the parsing stage (parsing is a process, during which the Python interpreter analyzes the grammatical structure of the program). Runtime errors are errors in a program that are not detected by the Python interpreter during its parsing stage. They are further divided into...

  • USE PYTHON 3, RUN THE CODE BEFORE POSTING THE ANSWER, AND READ THE ASSIGNMENT REQUIREMENTS NOTE CAREFULLY: Assignment...

    USE PYTHON 3, RUN THE CODE BEFORE POSTING THE ANSWER, AND READ THE ASSIGNMENT REQUIREMENTS NOTE CAREFULLY: Assignment Requirements NOTE: This program requires the use of if, elif, else, and casting between strings and numbers. The program should use the various code syntax covered in module 3. The program must result in print output using numeric input similar to that shown in the sample output below. Program: Cheese Order set values for maximum and minimum order variables set value for...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT