answer.
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
vfiekz
10 days ago
8

Write multiple if statements. If car_year is 1969 or earlier, print "Few safety features." If 1970 or later, print "Probably has

seat belts." If 1990 or later, print "Probably has antilock brakes." If 2000 or later, print "Probably has airbags." End each phrase with a period and a newline.
Sample output for input: 1995
Probably has seat belts.
Probably has antilock brakes.

My code:

car_year = int(input())

if car_year <= 1969:
print('Few safety features.')
elif car_year ==1970:
print('Probably has seat belts.')
elif car_year >= 1990:
print('Probably has seat belts.\nProbably has antilock brakes.')
else:
car_year >= 2000
print('Probably has airbags.')

My output that keeps failing:
Testing with input: 2001
Output differs. See highlights below.
Special character legend
Your output
Probably has seat belts.
Probably has antilock brakes.
Expected output
Probably has seat belts.
Probably has antilock brakes.
Probably has airbags.
Computers and Technology
1 answer:
Amiraneli [921]10 days ago
3 0

Your issue arises from using elif and if constructs. When one of your conditions is true, the others are bypassed. Instead, you should apply multiple if statements in place of elif and else. For example:

car_year = int(input())

if car_year <= 1969:

   print('Few Safety features.')

if car_year >= 1970:

   print('Probably has seat belts.')

if car_year >= 1990:

   print('Probably has antilock brakes.')

if car_year >= 2000:

   print('Probably has airbags.')

I have implemented my code using Python 3.8. I hope this proves beneficial.

You might be interested in
CHALLENGE ACTIVITY 2.1.2: Assigning a sum. Write a statement that assigns total_coins with the sum of nickel_count and dime_coun
Harlamova29_29 [932]

Answer:

In Python:

total_coins = nickel_count + dime_count

Explanation:

The sums of nickel_count and dime_count are combined and assigned to total_coins.

Cheers.

8 0
29 days ago
Sean is white hat hacker, who is demonstrating a network level session hijack attacks and as part of it, he has injected malicio
amid [800]

Answer:

The type of session hijacking attack that Sean is illustrating is Blind Hijacking, option C.

Explanation:

This is because he is inserting harmful data or commands into the compromised communications within the TCP session, regardless of the source-routing being turned off. He is capable of sending the data or commands, but does not have the ability to view the responses.

3 0
8 days ago
Debug the program so it prints the factorial of a positive integer entered by the user. This is calculated by multiplying all th
Natasha_Volkova [897]
The primary issue was declaring int prod within the while loop, which caused prod to reset to 1 each time the loop executed.
3 0
21 day ago
A company operates on two types of servers: 2 large servers (L) and 4 smaller servers (S), with a combined total of 64GB RAM. Th
oksian1 [797]

Reasoning:

Let's denote the size of a large server as L and the size of a smaller server as S.

According to the data provided, we have two equations:

2L + 4S = 64.............(1)

and

L + 3S = 40...............(2)

To solve the equations, we proceed as follows:

2(2)-(1)

2L - 2L + 6S - 4S = 2*40 - 64

2S = 16

thus, S = 8..................(3), which indicates the size of the small server

Using (3) in (2) yields

L + 3(8) = 40

L = 40 - 24 = 16..............indicating the size of the large server

8 0
8 days ago
Assume that you are testing the Orders database introduced in Watt (2014) - Appendix C. Discuss the problems and possible conseq
ivann1987 [930]

Answer:

129 \frac{2}{?} 23.4. \div 164 \times 5y1 +. \\.00487ggh

6 0
18 days ago
Other questions:
  • The Pentium 4 Prescott processor, released in 2004, had a clock rate of 3.6 GHz and voltage of 1.25 V. Assume that, on average,
    8·1 answer
  • A pedometer treats walking 2,000 steps as walking 1 mile. Write a program whose input is the number of steps, and whose output i
    15·1 answer
  • RADIAC instruments that operate on the ionization principle are broken down into three main categories based on what?
    15·1 answer
  • Widget Corp. wants to shift its list of inventory to a cloud so that its different branches can access it easily. The company ne
    7·1 answer
  • One form of Intrusion Detection System (IDS) starts operation by generating an alert for every action. Over time, the administra
    5·1 answer
  • Which of the following is opened when the Find command is clicked?
    12·1 answer
  • Assign to avg_owls the average owls per zoo. Print avg_owls as an integer. Sample output for inputs: 1 2 4 3
    7·1 answer
  • James is an intern in a film production company. On his first day, James’ boss, Monica, tells him, “Before anything else, let me
    9·1 answer
  • A router has a valid operating system and a configuration file stored in nvram. the configuration file contains an enable secret
    10·1 answer
  • What problem does the DNS solve? How does the DNS help the world wide web scale so that billions of users can access billions of
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!