Featured Posts

Start Your Journey with Linux Command Line

Image
🐧 Mastering the Linux Command Line Kali Linux Command Line Your Complete Guide: From Beginner to Confident User 35+ Essential Commands Covered with Real Examples Whether you're a developer, system administrator, or just curious about Linux, mastering the command line is an essential skill that will dramatically boost your productivity. This comprehensive guide breaks down the most critical Linux commands into logical categories with real, copy-paste examples you can try right now. We'll progress from basic file navigation to advanced system administration and network analysis, giving you a clear path to command-line proficiency. 📁 Section 1: The Core Workflow - Navigation Essentials Every Linux session follows a natural flow: figure out where you are, see what's around you, move to where you need to be, and then work with files. Let's master each step. pwd → ls ...

Python LAB: Comparison operators and conditional execution

PCAP LAB: Comparison operators and conditional execution

If you're taking PCAP - Programming Essentials In Python , you may have encountered this question in LAB: Comparison operators and conditional execution

Scenario

Spathiphyllum, more commonly known as a peace lily or white sail plant, is one of the most popular indoor houseplants that filters out harmful toxins from the air. Some of the toxins that it neutralizes include benzene, formaldehyde, and ammonia.

Imagine that your computer program loves these plants. Whenever it receives an input in the form of the word Spathiphyllum, it involuntarily shouts to the console the following string: "Spathiphyllum is the best plant ever!"

Write a program that utilizes the concept of conditional execution, takes a string as input, and:

prints the sentence "Yes - Spathiphyllum is the best plant ever!" to the screen if the inputted string is "Spathiphyllum" (upper-case)

prints "No, I want a big Spathiphyllum!" if the inputted string is "spathiphyllum" (lower-case)

prints "Spathiphyllum! Not [input]!" otherwise. Note: [input] is the string taken as input.

Test your code using the data we've provided for you. And get yourself a Spathiphyllum, too!

Test Data

Sample input: spathiphyllum

Expected output: No, I want a big Spathiphyllum!

Sample input: pelargonium

Expected output: Spathiphyllum! Not pelargonium!

Sample input: Spathiphyllum

Expected output: Yes - Spathiphyllum is the best plant ever!

The Code:

plant = input("What is the plant's name? : ")

if plant == "Spathiphyllum":
    print("Yes - Spathiphyllum is the best plant ever!")
elif plant == "spathiphyllum":
    print("No, i want a big Spathiphyllum!")
else:
    print("Spathiphyllum! Not" , plant , "!")
-------------------------------------------------------------------------------------

Comments