1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
eimsori [14]
3 years ago
12

Write a small program that takes in two numbers from the user. Using an if statement and an else statement, compare them and tel

l the user which is the bigger number. Also, consider what to output if the numbers are the same.
Test your program in REPL.it, and then copy it to your Coding Log.

(If you’re up for an extra challenge, try extending the program to accept three numbers and find the biggest number!)

And only give me a good answer not some random letters plz. ty
Computers and Technology
1 answer:
ArbitrLikvidat [17]3 years ago
4 0

Answer:

4. Conditionals

4.1. The modulus operator

The modulus operator works on integers (and integer expressions) and yields the remainder when the first operand is divided by the second. In Python, the modulus operator is a percent sign (%). The syntax is the same as for other operators:

>>> quotient = 7 / 3

>>> print quotient

2

>>> remainder = 7 % 3

>>> print remainder

1

So 7 divided by 3 is 2 with 1 left over.

The modulus operator turns out to be surprisingly useful. For example, you can check whether one number is divisible by another—if x % y is zero, then x is divisible by y.

Also, you can extract the right-most digit or digits from a number. For example, x % 10 yields the right-most digit of x (in base 10). Similarly x % 100 yields the last two digits.

4.2. Boolean values and expressions

The Python type for storing true and false values is called bool, named after the British mathematician, George Boole. George Boole created Boolean algebra, which is the basis of all modern computer arithmetic.

There are only two boolean values: True and False. Capitalization is important, since true and false are not boolean values.

>>> type(True)

<type 'bool'>

>>> type(true)

Traceback (most recent call last):

 File "<stdin>", line 1, in <module>

NameError: name 'true' is not defined

A boolean expression is an expression that evaluates to a boolean value. The operator == compares two values and produces a boolean value:

>>> 5 == 5

True

>>> 5 == 6

False

In the first statement, the two operands are equal, so the expression evaluates to True; in the second statement, 5 is not equal to 6, so we get False.

The == operator is one of the comparison operators; the others are:

x != y               # x is not equal to y

x > y                # x is greater than y

x < y                # x is less than y

x >= y               # x is greater than or equal to y

x <= y               # x is less than or equal to y

Although these operations are probably familiar to you, the Python symbols are different from the mathematical symbols. A common error is to use a single equal sign (=) instead of a double equal sign (==). Remember that = is an assignment operator and == is a comparison operator. Also, there is no such thing as =< or =>.

4.3. Logical operators

There are three logical operators: and, or, and not. The semantics (meaning) of these operators is similar to their meaning in English. For example, x > 0 and x < 10 is true only if x is greater than 0 and less than 10.

n % 2 == 0 or n % 3 == 0 is true if either of the conditions is true, that is, if the number is divisible by 2 or 3.

Finally, the not operator negates a boolean expression, so not(x > y) is true if (x > y) is false, that is, if x is less than or equal to y.

4.4. Conditional execution

In order to write useful programs, we almost always need the ability to check conditions and change the behavior of the program accordingly. Conditional statements give us this ability. The simplest form is the ** if statement**:

if x > 0:

   print "x is positive"

The boolean expression after the if statement is called the condition. If it is true, then the indented statement gets executed. If not, nothing happens.

The syntax for an if statement looks like this:

if BOOLEAN EXPRESSION:

   STATEMENTS

As with the function definition from last chapter and other compound statements, the if statement consists of a header and a body. The header begins with the keyword if followed by a boolean expression and ends with a colon (:).

The indented statements that follow are called a block. The first unindented statement marks the end of the block. A statement block inside a compound statement is called the body of the statement.

Each of the statements inside the body are executed in order if the boolean expression evaluates to True. The entire block is skipped if the boolean expression evaluates to False.

There is no limit on the number of statements that can appear in the body of an if statement, but there has to be at least one. Occasionally, it is useful to have a body with no statements (usually as a place keeper for code you haven’t written yet). In that case, you can use the pass statement, which does nothing.

if True:          # This is always true

   pass          # so this is always executed, but it does nothing

You might be interested in
Jenny wants to create a résumé after a two-years gap. What should she consider?
gavmur [86]

She should consider jail time.

3 0
3 years ago
Read 2 more answers
Machines may aid in making work easier over a longer distance. true or false.
Dmitry [639]
This seems like more of an opinion based question, but since they added "over a longer distance" If I were you I would go with false.
4 0
3 years ago
Hank is the network administrator responsible for managing the web server cluster for an e-commerce company. He’s worried about
statuscvo [17]

Answer: ....

If one load balancer fails, the secondary picks up the failure and becomes active. They have a heartbeat link between them that monitors status. If all load balancers fail (or are accidentally misconfigured), servers down-stream are knocked offline until the problem is resolved, or you manually route around them.

Explanation:

Load balancing is a technique of distributing your requests over a network when your server is maxing out the CPU or disk or database IO rate. The objective of load balancing is optimizing resource use and minimizing response time, thereby avoiding overburden of any one of the resources.

The goal of failover is the ability to continue the work of a particular network component or the whole server, by another, should the first one fail. Failover allows you to perform maintenance of individual servers or nodes, without any interruption of your services.

It is important to note that load balancing and failover systems may not be the same, but they go hand in hand in helping you achieve high availability.

3 0
3 years ago
Given an array declared to hold 100 values, the smallest index that can be used with the array is
Aneli [31]
In C influenced languages - 0.
8 0
3 years ago
If a preferred (faster) learned route over a WAN has administrative distance 110 that competes with a static backup (slower) rou
almond37 [142]

The engineer will need to set the distance to 130 for the static link so that it becomes a floating static route.

<h3>What is Floating static routes?</h3>

This is known to be a static routes that is said to have a kind of administrative distance that is also known to be bigger than the administrative distance of any other static route or dynamic routes.

Note that the value 130 stands for the next most logical value, nd as such it is to know that the right route comes first in the steps for administrative distance.

Learn more about WAN from

brainly.com/question/11352260

5 0
2 years ago
Other questions:
  • Cameron oversees inventory tracking in her school store. Which feature in a database allows her to organize the items from highe
    6·1 answer
  • How long does it take to send a 8 MiB file from Host A to Host B over a circuit-switched network, assuming: Total link transmiss
    11·1 answer
  • A USB device used to transfer photos from the memory card to a hard drive is called a _____.
    5·2 answers
  • Write a Python program that prompts the user for the cost of two items to be purchased. Then prompt the user for payment. If the
    11·1 answer
  • Which software application offers a variety of templates for creating reports, flyers, and newsletters that you can access withi
    12·1 answer
  • The road is closed a head
    9·1 answer
  • How many types of sharing of Google Forms are possible?
    15·1 answer
  • Which statistical measurement tools should be
    8·1 answer
  • Which option should Gina click to edit the text contained in a text box on a slide in her presentation?
    13·2 answers
  • Select the correct answer..
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!