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
What are the two basic windows 8 settings for network security?
maks197457 [2]

The two basic windows 8 setting for network security are Public and private network. The private network settings mean that you can link home group and make remote desktop connections. Public network settings entail the greatest privacy. You should make sure file or device sharing is disabled for having data copy.

<span> </span>

 

7 0
3 years ago
What are some similarity's between NES console and consoles today
blondinia [14]

Answer:

Old game consoles

New game consoles

Old games consoles like the NES, SNES, the SEGA Genesis were manufactured during the 1970's This generation started in the first and ends in the fifth

New game 3-D consoles like the PS3, X-Box 360 and the Wii U were manufactured during the late 90s to right now. This generation started in the sixth and ends at the eighth.

Facts

They have introduce a lot of game genres and characters like the Mario bros, The Legend of Zelda series, The Tetris game, and Sonic the Hedgehog series.

Genres like platformers and side scrollers were introduced in the 2-D era

New game consoles has introduce game genres like First Person Shooters. Games like Call of Duty and Halo are examples

The answer

The differences between an old console and a new console is not only the modeling of either the game console, but the functional properties and the way it operates. From each generation , there are about eight generations of consoles right now

The difference between an old generation of consoles and a new genration of console

Sources

http://www.answers.com/Q/What_is_the_difference_between_the_old_games_consoles_and_the_new_games_consoles

Pictures and more facts

The X-Box sucessor, the X-Box 360 was released in November 22, 2005 in the United States. Games like Halo and Call of Duty are the games that introduced really good First-Person Shooters

The Playstation 1, PSx, or the PS1 was made in September 9th 1995 in North America. The games that was in for the playstation is the famous Crash Bandicoot and Spyro the Dragon series and a few 2-d games.

The second picture the Super Nintendo Entertainment System or the SNES, was release to America in 1991 and is the sucessor of the NES

The games that was in the system was Super Mario World 1-2, The legend of zelda 3, which were one of the best selling games on the system

The first picture the Nintendo Entertainment System or the NES, that was released to America in 1985 and it was the best selling console at its time.

The games it introduce was of course Super Mario Bros 1-3, The Legend of Zelda 1-2

The third and last picture is the SEGA Overdrive or SEGA Genesis was releases to America in 1989 and rivaled with the SNES during the time.

Games that was with the system was SEGA's blue mascot Sonic the Hedgehog 1-3 and Knuckles, Teenage Mutant Ninja Turtles

PS1 fact

Even though the PS1 has its 2-D games, it also has 3-D games like the Crash Bandicoot and Spyro series made by Naughty Dog, who also did the Last of us game

Explanation:

the similarities are they both play games they both load some type of disk etc.

3 0
3 years ago
Read 2 more answers
Now plz<br>draw the main memory​
Sophie [7]

Answer: Here is my answer- I hope it helps! Btw I did search this up but I change some words so I don't get in trouble again ; - ;

Explanation: A unit of measurement is a definite importance of an amount, defined and adopted by convention or by law, that is used as a standard for measurement of the same kind of amount. Any other amount of that kind can be expressed as a multiple of the unit of measurement. For example, a length is a physical amount.

3 0
3 years ago
Secondary storage is also called?
Alekssandra [29.7K]

it is also called external storage

4 0
4 years ago
True or False?
patriot [66]

Answer:

False

Explanation:

You can not plagiarize, no matter what.

3 0
4 years ago
Read 2 more answers
Other questions:
  • _____ is a valuable tool that enables you to find information on the web by specifying words or phrases know as keywords- which
    14·1 answer
  • Software that interpret commands from the keyboard and mouse is known as the
    13·1 answer
  • You're browsing the Internet and realize your browser is not responding. Which of the following will allow you to immediately ex
    5·2 answers
  • Angle, oblique, regular, demi, roman, heavy, extra bold, expanded, and compressed are ___________ . Select one: A. type styles B
    10·1 answer
  • This function receives first_name and last_name, then prints a formatted string of "Name: last_name, first_name" if both names a
    5·1 answer
  • According to a case study in one of our weekly chapter reading, nearly..................... percent of all employees send work e
    11·2 answers
  • Jenn wants to assign a value to the favorite car variable: favoriteCar = Toyota but gets an error message. What does she need to
    11·1 answer
  • Which of the following is a characteristic of vector graphics?
    15·2 answers
  • Providing captions and transcripts for videos on your website is a way of ensuring what?.
    7·1 answer
  • When methods have ____, other programs and methods may use the methods to get access to the private data.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!