0% found this document useful (0 votes)
44 views26 pages

Python Scenarion Without Scenario

The document outlines various Python programming scenarios for calculating costs, budgets, and other financial metrics, including grocery bills, movie ticket costs, and monthly savings. It provides test cases for each scenario to demonstrate expected outputs based on user inputs. Additionally, it includes conditional statements for tasks like outfit suggestions based on temperature and eligibility checks for activities or purchases.

Uploaded by

Amol Adhangale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views26 pages

Python Scenarion Without Scenario

The document outlines various Python programming scenarios for calculating costs, budgets, and other financial metrics, including grocery bills, movie ticket costs, and monthly savings. It provides test cases for each scenario to demonstrate expected outputs based on user inputs. Additionally, it includes conditional statements for tasks like outfit suggestions based on temperature and eligibility checks for activities or purchases.

Uploaded by

Amol Adhangale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 26

Grocery Bill Calculator

python scenario question: Grocery Bill Calculator: Quick and Easy with Operators!
You’re at a grocery store buying apples, bananas, and oranges. The prices per
kilogram are as follows: apples cost $3, bananas cost $2, and oranges cost $4.
Write a python program to calculate your total bill based on the weight of each
fruit you’re buying.

Test Case
Input:
Enter the weight of apples (kg): 2
Enter the weight of bananas (kg): 1
Enter the weight of oranges (kg): 1.5
Expected Output: Total bill: $14

Movie Ticket Cost


Calculate movie ticket costs scenario question with python operators
You’re going to the movies and need to calculate the total cost of tickets. Each
adult ticket costs $12 and each child ticket costs $8. Write a python program to
calculate the total cost based on the number of adult and child tickets.

Test Case
Input:
Enter the number of adult tickets: 2
Enter the number of child tickets: 3
Expected Output:Total cost: $48

Birthday Party Budget


Calculate your birthday party budget scenario question in python using operators.
You’re organizing a birthday party and need to calculate the total cost of party
items. Each party item costs $4, and you plan to buy 15 items. Write a python
program to compute the total cost of the party items.

Test Case
Input: 15
Expected Output:Total cost: $60.00
Splitting the Bill
Use python operators to split the bill scenario question:.
You and your friends went out to dinner, and the total bill needs to be split
equally among all the diners. Write a python program that asks for the total bill
amount and the number of people. The program should calculate and print the amount
each person needs to pay.

Test Case
Input:
Enter the total bill amount: $150
Enter the total bill amount: $150
Enter the number of people: 5
Expected Output: Each person needs to pay: $30
Calculate Total Monthly Savings
Calculate Monthly Savings in python using Operators scenario question:.
You have multiple sources of income and want to calculate your total savings for
the month after deducting expenses. First, calculate your total income by adding up
the income from different sources. Then, subtract the total expenses from this
total income to determine your monthly savings. Write a python program to perform
these calculations.

Test Case
Input:
Enter the amount of Income 1: $2000
Enter the amount of Income 2: $1500
Enter the amount of Income 3: $800
Enter the total expenses: $2500
Expected Output: Total Monthly Savings: $1800
Fuel Cost Estimator
Calculate fuel costs by applying python operators.
You’re planning a road trip and need to estimate the fuel cost. Write a python
program that asks for the trip’s distance, the car’s fuel efficiency (in kilometers
per liter), and the price of fuel per liter. The program should calculate the total
fuel cost.

Test Case
Input:
Enter the distance of the trip (in km): 300
Enter the fuel efficiency of the car (km per liter): 15
Enter the price of fuel per liter: 2.5
Expected Output: Total fuel cost: $50

Area of a Room
Calculate the area of a room with python operators.
You’re working on a home improvement project and need to calculate the area of a
rectangular room. Write a python program that asks for the length and width of the
room and calculates the area.

Test Case
Input:
Enter the length of the room (in meters): 5
Enter the width of the room (in meters): 4
Expected Output: Area of the room: 20 square meters
Monthly Loan Payment for a New Laptop
Use python operators to figure out monthly loan payments for a new laptop.
Imagine you’ve bought a new laptop for your studies and decided to finance it
through a loan. You need to figure out your monthly payment based on the total
amount of the loan, the monthly interest rate, and the number of months over which
you’ll repay the loan. Use the formula: M=(P×(1+r))/N where M is the monthly
payment, P is the total amount of the loan, r is the monthly interest rate, and N
is the number of months. Write a program in python to calculate this.

Test Case
Input:
Enter the total loan amount for the laptop: $1200
Enter the monthly interest rate (as a decimal): 0.015
Enter the number of months for repayment: 12
Expected Output: Monthly payment: $101.5

Painting a Room
Estimate room painting costs using python operators scenario problem
You’ve decided to paint your bedroom, and you want to calculate the total amount of
paint needed. You know that one can of paint covers a specific area in square feet.
Given the dimensions of your room (length, width, and height) and the area that one
can of paint covers, determine how many cans of paint you need to buy. Assume all
four walls are to be painted and you will not paint the ceiling or the floor. Write
a program in python to perform this calculation.

Test Case
Input:
Enter the length of the room in feet: 12
Enter the width of the room in feet: 10
Enter the height of the room in feet: 8
Enter the coverage area per can in square feet: 350
Expected Output: Cans of paint needed: 1.00571
The Farmer’s Harvest Calculation
Farmer's Harvest Revenue Calculator in python using Operators
A farmer wants to calculate the total revenue from selling his crops: wheat, corn,
and barley. He computes the revenue for each crop by multiplying the amount
harvested by the price per kilogram. After finding the revenue for each type of
crop, he adds them together to get the total revenue. Write a python program to
perform these calculations.

Test Case
Input:
Enter the amount of wheat harvested (in kg): 100
Enter the price per kg of wheat: $2
Enter the amount of corn harvested (in kg): 150
Enter the price per kg of corn: $1.5
Enter the amount of barley harvested (in kg): 200
Enter the price per kg of barley: $1.8
Expected Output:Total Revenue: $785
Space Equipment Purchase
scenario problem in python: Space equipment purchase
You’re preparing for an exciting adventure to a faraway planet, where you need
special equipment to succeed. Each unit you buy has a price, and you know exactly
how many units you need to take. Luckily, the supplier offers a discount of $60.00
for every 5 units you purchase. Before you complete your order, you need to figure
out the total cost after using this discount, ensuring you have everything you need
for the journey without spending too much. Write a python program to calculate the
final cost after applying the discount.

Test Case
Input:
Enter the price per unit: 550
Enter the number of units: 12
Expected Output:
Final cost after discount: $6480

Land Plot Calculator


scenario problem in python: Land plot calculator using operators
Imagine a farmer who wants to divide a big rectangular field into smaller square
plots for planting. The farmer knows the total area of the field and the size of
each square plot. To plan the planting, the farmer needs to find out how many of
these square plots can fit in the field and how much area will be left over. Write
a program in python to help the farmer calculate the number of complete square
plots that can fit and the leftover area.

Test Case
Input:
Enter the total area of the land: 1000
Enter the side length of one square plot: 15
Expected Output:
Number of complete square plots: 4
Remaining area: 100

Digital Clock Seconds Calculation


scenario problem in python time conversion using operators
You have a digital clock that shows hours, minutes, and seconds. Each time you set
the clock, you need to know how many total seconds have passed since midnight.
Write a program in python to convert the given time into the total number of
seconds from the start of the day, making it easier to manage and track time with
your clock.

Test Case
Input:
Enter hours: 2
Enter minutes: 30
Enter seconds: 45
Expected Output:
Total seconds since midnight: 9045

Construction Materials Calculation


scenario problem in python Construction material cost
As a project manager for a large construction site, you need to determine the
amount of cement required to complete the foundation of a building. The foundation
needs a certain volume of concrete to be poured. Each bag of cement contributes a
specific volume to the concrete mix, and you can only order cement in full pallets,
where each pallet contains a fixed number of bags. To meet or exceed the required
concrete volume, you need to calculate how many pallets of cement are necessary.
Additionally, because you can only order full pallets, there will be some excess
concrete due to the rounding up of pallets.
Write a python program to:
1. Calculate the minimum number of pallets needed to meet or exceed the required
volume of concrete.
2. Determine the amount of excess concrete produced due to ordering full pallets.

Test Case
Input:
Enter the required volume of concrete in cubic meters: 1000
Enter the volume contributed by one bag of cement in cubic meters: 2
Enter the number of bags in one pallet: 40
Expected Output:
Total pallets required: 13
Excess concrete produced: 40 cubic meters

Inventory Code Analysis


scenario problem in python: Inventory code analysis
You are working on a system that processes inventory codes, where each code is a
four-digit number used to identify different product categories. Each product gets
a unique four-digit code to help categorize it accurately within the inventory. To
improve the system’s functionality, you need to write a python program. This
program should read a four-digit inventory code from the user, separate the code
into its individual digits, and then display each digit separately. This process
will help in better managing and analyzing the product information.

Test Case
Input:
Enter a four-digit inventory code: 2024
Expected Output:
Digits of the inventory code are:
Thousands place: 2
Hundreds place: 0
Tens place: 2
Ones place: 4

Profit Margin Calculation


scenario problem in python: profit margin calculation
A company sells a product for a certain amount. The costs to make the product and
extra expenses like shipping and taxes are also known. You need to determine the
profit margin percentage, which shows how much profit is made compared to the
selling price. This percentage shows the profit as a part of the selling price.
Write a program in python that takes the selling price, production cost, and
additional expenses as input, and then calculates and displays the profit margin
percentage.

Test Case
Input:
Enter the selling price of the product: 200
Enter the production cost of the product: 120
Enter additional costs (shipping, taxes, etc.): 30
Expected Output:
Profit Margin Percentage: 25%

Subscription Budget Planner


scenario problem in python: Subscription budget planner
You want to enroll in an online course platform that requires a monthly
subscription fee. You have some initial savings set aside and plan to save a fixed
amount each month to cover the subscription cost. To manage your finances
effectively, you want to calculate your total savings after a certain number of
months, determine how many full months of subscriptions you can afford, and find
out how much money will be left after paying for those months. Additionally, you
want to know how much more you need to save to afford another full month of
subscription. This way, you can plan your savings to maintain the subscription as
long as possible and understand what additional savings are required to extend it
further. Write python code to perform these calculations and display the results
based on the inputs for initial savings, monthly savings, subscription fees, and
the number of months you plan to save.

Test Case
Input:
Enter initial savings: 100
Enter monthly savings: 50
Enter monthly subscription fee: 60
Enter the number of months you plan to save: 6
Expected Output:
After 6 months:
Total Savings: 400
Full Months Affordable: 6
Remaining Money: 40
Additional Savings Needed for Next Month: 20

Total Travel Time Calculation


scenario problem in python: Time travel calculation
You are a travel coordinator who needs to prepare a detailed schedule for a
passenger’s trip. The passenger’s journey includes a main flight, a layover, and a
connecting flight. To help the passenger understand how long their entire trip will
take, you need to add up the time of the main flight, the layover, and the
connecting flight. Each part of the trip is given in hours and minutes. Your task
is to write code in python to calculate the total travel time and show it in hours
and minutes.

Test Case
Input:
Enter the main flight duration in hours: 3
Enter the main flight duration in minutes: 45
Enter the layover duration in hours: 2
Enter the layover duration in minutes: 30
Enter the connecting flight duration in hours: 1
Enter the connecting flight duration in minutes: 15
Expected Output:
Total time spent traveling, including layovers and connecting flights, is: 7 hours
and 30 minutes.

Car Loan Plan


scenario problem in python: Car loan plan
You’ve decided to buy your first car and need to take out a loan to finance it. You
have a specific budget in mind for your monthly installment and know the total cost
of the car. You want to calculate how many months it will take to pay off the loan
based on your monthly installment and the interest rate applied to the loan.
Additionally, you want to know the total cost of the loan, including interest.
Write a python program that calculates the number of months required to repay the
loan and the total cost, including the interest.

Test Case
Input:
Car cost: 20000
Down payment: 5000
Interest rate: 5
Monthly installment: 300
Expected Output:
Total loan amount (including interest): 15750
Number of months to pay off the loan: 52.5

Pocket Money Saver


scenario problem in python: Pocket money saver
You receive a base pocket money amount each week, which you enter into the system,
and you have a weekly expense. For the week, a performance multiplier of 1.25 is
applied to your base pocket money. Additionally, if your total savings after
considering the expense exceed $120, you receive a fixed bonus of $30. On the other
hand, if your total savings fall below $60, you face a fixed penalty of $20.
Calculate your total savings after one week. Write a program in python to perform
this calculation.

Test Case
Input:
Enter your base pocket money: $110
Enter your weekly expense: $10
Expected Output: Total savings after one week: $151.875

Outfit Suggestion Based on Weather


Scenario Based question weather report in if-else condition in python
On a beautiful day, you need to decide what to wear. Write a program that takes the
current temperature as input and suggests the appropriate clothing. If the
temperature is above 25°C, recommend wearing a shirt; otherwise, recommend wearing
a jacket.

Test Case:
Input: 30
Expected Output: “Wear a shirt.”

Amusement Park Ride


conditional statements in If else scenario based questions amusement ride
You’re at an amusement park, and you want to know if you can ride a roller
coaster. The park requires that riders must be at least 120 cm tall. Write a
program that takes your height as input and tells you whether you can ride the
roller coaster.
Test Case:
Input: 130
Expected Output: “You can ride the roller coaster!”

Movie Rating Check


Movie Rating Checking In python using conditional statements
You want to watch a movie, but first, you need to check if you’re old enough. The
minimum age requirement for the movie is 18 years. Write a program in python to
check the eligibility.

Test Case:
Input: 20
Expected Output: You are old enough to watch this movie.

Fitness App Rewards


Fitness app system in C+= using Conditional statements
You’re using a fitness app that rewards you if you log more than 1000 steps in a
day. Write a program in python that takes the number of steps logged as input and
tells you if you’ve earned a reward.

Test Case:
Input: 1200
Expected Output: “Congratulations! You’ve earned a reward!”

Coffee Size Recommendation


Coffee Recommendation in python using Conditional Statements with if-else
You determine the appropriate coffee size based on the amount of coffee you
consume. Write a python program that takes the volume of coffee in milliliters and
recommends a coffee size. If the volume is more than 350 ml, recommend a “Large”
size; if it’s between 200 ml and 350 ml, recommend a “Medium” size; and if it’s
less than 200 ml, recommend a “Small” size.

Test Case:
Input: 220
Expected Output: “Medium”

Store Discount Eligibility


Store Discount Eligibility using if-else in python
You’re shopping at a store that offers a discount if you spend $50 or more. Write
a python program to check if the user is eligible for the discount based on their
total purchase amount.

Test Case:
Input: 65.00
Expected Output: You are eligible for a discount!

Bank Balance Alert


Banking Alert Using If-else condition in python
You want to check your bank balance before making a purchase. If your balance is
below $100, you receive an alert that your funds are low. Otherwise, you’re told
that your balance is sufficient.

Test Case:
Input: 75.50
Expected Output: Alert! Your balance is low.

Rental Car Cost Calculator


Car Rent Calculator using Conditional Statements in python with if-else conditions
You need to determine the cost of renting a car based on the number of days rented:
For up to 3 days, the rate is $50 per day.
For 4 to 7 days, the rate is $40 per day for days 4 through 7.
For rentals longer than 7 days, the rate is $30 per day for the days beyond 7, with
previous rates still applicable.
Write a program to calculate the total rental cost.

Test Case:
Input: 10 days
Expected Output: “Total rental cost: $410.00”

Utility Bill Calculator


utility Bill Calculator in python using if else conditional statements
You need to calculate the utility bill based on the total number of units consumed:

For up to 100 units, the charge is $0.50 per unit. For units between 101 and 200,
the rate is $0.75 per unit for the units beyond the first 100. For units exceeding
200, the cost is $1.00 per unit for units above 200, while the previous rates still
apply.
Write a program to compute the total utility bill based on these rates.

Test Case:
Input: 250 units
Expected Output: “Total utility bill: $215.00”
Speeding Ticket Calculator
Speeding ticket calculator in python using conditional statements
You’re driving and want to avoid a speeding ticket. The speed limit is 60 km/h. If
you drive within the speed limit, you’re safe. If you exceed the limit by up to 10
km/h, you get a warning. If you exceed it by more than 10 km/h, you receive a
ticket. Write a python program to check the speed and assign a ticket for violating
the conditions.

Test Case:
Input: 75
Expected Output: You are speeding! You will receive a ticket.

Treasure Hunt
scenario-based coding question on if else with multiple conditions - Treasure Hunt
You are a developer tasked with creating a treasure hunt game. In this game, the
player searches for a hidden treasure at one of four locations. The player has a
couple of tools to find the treasure a key and a map but their success in finding
the treasure depends on whether they have these tools.

Locations:
Location 1: The player can search here, but the treasure is not located there.
Location 2: The map indicates that the treasure might be here, but only players
with a map will receive this clue.
Location 3: This is a decoy location where the treasure is not hidden.
Location 4: The treasure might be locked behind a door, and the player will need a
key to access it.
Rules:
1. The player must first indicate whether they have a key and a map.
2. If the player has a map, they will receive a clue that the treasure may be
hidden at Location
3. If the player chooses Location 4, they will need a key to unlock the door and
collect the treasure.
4. If the player searches in the wrong location (Location 1 or Location 3), they
will be told that the treasure is not there, and they can try again.

The player’s decisions on where to search for the treasure will determine whether
they succeed or not.

Test Case 1:
Input:

Has Key: y
Has Map: y
Location chosen: 2

Expected Output:

Do you have a key? (y/n): y


Do you have a map? (y/n): y
You have a map! The map shows the treasure might be at Location 2.
Choose a location to search for the treasure (1, 2, 3, or 4): 2
Congratulations! You found the treasure at Location 2 using the map!

Test Case 2:
Input:

Has Key: n
Has Map: y
Location chosen: 4

Expected Output:

Do you have a key? (y/n): n


Do you have a map? (y/n): y
You have a map! The map shows the treasure might be at Location 2.
Choose a location to search for the treasure (1, 2, 3, or 4): 4
The treasure is locked behind a door. You need a key to access Location 4!

The Alien Ship


scenario-based coding question on if else with multiple conditions - The alien ship
You have discovered a mysterious alien ship with three adjustable settings: Power
Level, Frequency, and Mode. The artifact’s effect is determined by the combination
of these settings. The ship can produce various effects based on specific ranges
and combinations of settings. The settings might not always align perfectly due to
possible defects in the dials.
Task: Write a program to determine the ship effect based on the following settings:
Power Level: An integer ranging from 1 to 20.
Frequency: An integer ranging from 40 to 100.
Mode: A string which can be “Basic”, “Standard”, or “Advanced”.
Conditions:
In the case Power Level is more than 15, Frequency is greater than 70, and Mode is
“Advanced”, the effect is “Quantum Leap”.On the other hand when Power Level is
higher than 15, Frequency is 70 or less, and Mode is “Standard”, the effect is
“Energy Surge”.Also, if the Power Level is greater than 10, Frequency is greater
than 60, and Mode is “Basic”, the effect is “Temporal Shift”. When Power Level is
15 or less and Frequency is 60 or less, or Mode is “Basic” and Power Level is
greater than 5, the effect is “Energy Shield”. But when the Power Level is greater
than 10, Frequency is greater than 50, and Mode is “Standard”, the effect is
“Stability Boost”. Besides that, if none of the above conditions are met, the
effect is an “Unknown Signal”.

User provides values for Power Level, Frequency, and Mode.


Display the effect of the ship based on the input settings.
Test Case 1
Input:
Power Level: 18
Frequency: 75
Mode: “Advanced”

Expected Output:
Effect: Quantum Leap

Test Case 2
Input:
Power Level: 12
Frequency: 55
Mode: “Standard”

Expected Output:
Effect: Stability Boost

The Ancient Codebreaker


scenario-based coding question on if else with multiple conditions - The Alien Ship
Imagine you have an ancient codebreaking device that helps you decode secret
messages. This device has three important settings: Difficulty Level, Tool Quality,
and Expertise. The Difficulty Level is a number between 1 and 10 that shows how
challenging the code is to crack. Tool Quality, also a number between 1 and 10,
indicates how good your tools are for decoding. Lastly, Expertise refers to your
skill level, which can be “Beginner,” “Intermediate,” “Advanced,” or “Expert.”
Depending on these settings, the device will suggest different methods to decode
the message. For example, if the Difficulty Level is above 8, Tool Quality is above
9, and your Expertise is “Expert,” the device will recommend a “Quantum Decryption”
method. On the other hand, if the Difficulty Level is above 8, Tool Quality is 9 or
less, and your Expertise is “Advanced,” it will suggest a “Complex Algorithm.”
There are other combinations as well, such as “Advanced Technique,” “Optimized
Approach,” and more, depending on the values you enter.
Your task is to write a program that takes these three settings as input and tells
you which decoding method the device will suggest. If none of the predefined
combinations match, the program should indicate that the decoding method is
“Unknown.”

Test Case 1:
Input:
Difficulty Level: 9
Tool Quality: 10
Expertise: “Expert”

Expected Output:
“Decode Method: Quantum Decryption”

Test Case 2:
Input:
Difficulty Level: 6
Tool Quality: 4
Expertise: “Intermediate”

Expected Output:
“Decode Method: Practical Method”

The Loan Approval System


scenario-based coding question on if else with multiple conditions - Loan approval
system
Imagine you’re working for a bank, and you need to decide if a customer qualifies
for a loan based on their financial details. The decision depends on three factors:
their credit score, their existing debt, and the amount of loan they require.
First, the bank checks the debt-to-income ratio by dividing the customer’s total
debt by their income. If the debt-to-income ratio exceeds 40%, the loan is denied
due to a high debt load. If the ratio is within acceptable limits, the credit score
is checked. Customers with a credit score of 750 or higher are approved with the
best interest rate, while those with a credit score between 700 and 749 receive a
standard interest rate. If the credit score is below 700, the loan is denied.
Finally, if the loan amount requested exceeds 50% of the customer’s income, the
loan is denied even if other conditions are met. Your task is to write a program
that inputs these values and outputs the loan status and interest rate based on
these criteria.

Test Case 1:
Input: Credit Score: 780
Income: $80,000
Debt: $20,000
Loan Amount Requested: $30,000

Expected Output: “Loan Status: Approved with best interest rate”

Test Case 2:
Input: Credit Score: 690
Income: $50,000
Debt: $30,000
Loan Amount Requested: $10,000

Expected Output: “Loan Status: Denied due to high debt-to-income ratio”

Electric Vehicle Charging Station


scenario-based coding question on if else with multiple conditions - Electric
vehicle charging
You are tasked with designing a smart charging system for electric vehicles in a
futuristic city. The system calculates the appropriate charging rate based on three
key factors: the type of vehicle, its battery level, and the time of day. Here’s
how the charging rate is determined:

Vehicle Types:
Sedan: Discounted charging rate during Off-Peak hours.
SUV: Standard charging rate regardless of other factors.

Battery Levels:
Below 15%: Prioritized charging (higher rate).
50% or more: Increased rate during Peak hours.

Time of Day:
Off-Peak: Discounted rate for Sedans.
Peak: Increased rate if battery is 50% or more.

Charging Rates:
Standard Rate: $10 per kWh
Discounted Rate: $7 per kWh
Increased Rate: $15 per kWh
Prioritized Charging Rate: $20 per kWh

Test Case 1:
Input: Vehicle Type: Sedan
Battery Level: 10
Time of Day: Off-Peak
Expected Output: Final Charging Rate: $5 per unit

Test Case 2:
Input: Vehicle Type: SUV
Battery Level: 60
Time of Day: Peak

Expected Output: Final Charging Rate: $4 per unit

The Wizard’s Spells


Wizard Based game in python using conditional statements with multiple conditions
In a magical realm where wizards regularly cast spells, calculating the cost of
casting a spell involves several key factors. Each type of spell has a base cost
associated with it, and depending on the number of spells, the use of rare runes,
the rank of the wizard performing the spell, and whether the spell is for a special
occasion, additional charges are applied. Here’s how the pricing works:

Spell Type:
Offensive: $300 base cost.
Defensive: $400 base cost.
Utility: $500 base cost.
Number of Spells:

Few (1-3 spells): Add $50.


Moderate (4-6 spells): Add $100.
Many (7 or more spells): Add $200.
Additional Charges:

Rare Runes: If rare runes are used, add $150 to the total cost.

High-Ranking Wizard: If the spell is cast by a high-ranking wizard, add $200 to the
total cost.

Special Occasion: If the spell is cast for a special event or occasion, add $250 to
the total cost.

The program you are tasked with building should take these factors into account to
calculate the final enchantment cost. The user will input the type of spell, the
number of spells, whether rare runes are used, if a high-ranking wizard is
involved, and whether the spell is for a special occasion. Based on this
information, the program should calculate and display the final cost of the
enchantment.

Test Case 1:
Input: Spell Type: Defensive
Number of Spells: Many
Rare Runes: Yes
High-Ranking Wizard: No
Special Occasion: Yes

Expected Output: Final Enchantment Cost: $850

Test Case 2:
Input: Spell Type: Offensive
Number of Spells: Few
Rare Runes: No
High-Ranking Wizard: Yes
Special Occasion: No
Expected Output: Final Enchantment Cost: $500

Magical Creatures
scenario-based coding question on if else with multiple conditions - Mythical
creatures
You are tasked with designing a program to calculate the total cost of setting up a
magical shop for mystical creatures. The base cost for establishing the shop is
$400, but additional charges will depend on several factors, such as the type of
creature, the number of creatures, special habitat requirements, whether the shop
is located in a mystical forest, and if the creatures are classified as endangered.
The cost of the shop is influenced by these elements:

Creature Type:
Dragons add $300 to the base cost.
Unicorns add $200 to the base cost.
Phoenixes add $150 to the base cost.

Number of Creatures:
Few (1-3 creatures) adds $100.
Several (4-6 creatures) adds $200.
Many (7 or more creatures) adds $300.

Special Habitats: If special habitats are required, it adds $250.


Mystical Forest: If the shop includes a mystical forest, it adds $100.
Endangered Creatures: If the creatures are endangered, it adds $400.

Your task is to create a program that takes inputs for the creature type, the
number of creatures, and other features (such as special habitats, mystical forest,
and endangered status) to compute and display the total cost of setting up the
shop.

Test Case 1
Inputs:
Creature Type: Unicorns
Number of Creatures: Several
Special Habitats: Yes
Mystical Forest: No
Endangered: Yes

Expected Output:
Final Shop Expenses: $1150

Test Case 2
Inputs:
Creature Type: Dragons
Number of Creatures: Few
Special Habitats: No
Mystical Forest: Yes
Endangered: No

Expected Output:
Final Shop Expenses: $800

Adventure Park Ticket Pricing


scenario-based coding question on if else with multiple conditions - Adventure park
You’re planning a day at an amusement park and need to calculate the total cost of
tickets. The park offers different ticket types: Regular, Fast-Pass, and Group,
each with its own price adjustment. Additionally, the price can vary depending on
the time of day (Peak or Off-Peak), whether it’s a Weekend or Weekday, and whether
you purchase tickets for multiple attractions. The base price for each ticket is
$100, and several factors will adjust this price to determine the final amount you
need to pay.
The ticket pricing is determined as follows:

Ticket Type:
Regular: No change (remains $100).
Fast-Pass: Adds $30 to the base price.
Group: Subtracts $20 from the base price.

Time of Day:
Peak: Adds $20.
Off-Peak: No change.

Day of Visit:
Weekend: Adds $15.
Weekday: No change.

Multi-Attraction Purchase:
Yes: Subtracts $25.
No: No change.

Your task is to write a program that calculates the final ticket price by
considering these factors.

Test Case 1
Inputs:
Ticket Type: Fast-Pass
Time of Day: Peak
Day: Weekend
Multi-Attraction Purchase: Yes

Expected Output:
Final Ticket Price: $120

Test Case 2
Inputs:
Ticket Type: Group
Time of Day: Off-Peak
Day: Weekday
Multi-Attraction Purchase: No

Expected Output:
Final Ticket Price: $80

Hotel Reservation System


scenario-based coding problem on if else with multiple conditions - Hotel
reservation system
You’re managing a hotel reservation system that needs to calculate the final room
cost based on several factors. The hotel offers different room types—Standard,
Deluxe, and Suite—each with its own base price. The total price is adjusted based
on the time of year (season), the guest’s loyalty status, the duration of stay,
whether the reservation is for a weekend or weekday, and the selected meal plan.
Guests can also opt for additional services such as spa treatments or guided tours,
which add a flat fee to the total cost.
The price adjustments are as follows:

Room Type:
Standard: $150 per night.
Deluxe: $250 per night.
Suite: $400 per night.

Season:
Off-Season: Subtract $50 per night.
Peak: No change.

Loyalty Status:
Loyal: Subtract $30 per night.
New: No change.

Duration of Stay:
If the stay is more than 5 nights, subtract $100 from the total.

Day of Reservation:
Weekend: Add $40 per night.
Weekday: No change.

Meal Plan:
None: No change.
Breakfast: Add $20 per night.
Full-Board: Add $50 per night.

Additional Services:
Yes: Add a flat fee of $150.
No: No change.

Test Case 1
Inputs:
Room Type: Deluxe
Season: Peak
Loyalty Status: Yes
Stay Duration: 5 nights
Day of Reservation: Weekend
Meal Plan: Full-Board
Additional Services: Yes

Expected Output:
Final Room Cost: $960

Test Case 2
Inputs:
Room Type: Standard
Season: Off-Season
Loyalty Status: No
Stay Duration: 3 nights
Day of Reservation: Weekday
Meal Plan: Breakfast Only
Additional Services: No

Expected Output:
Final Room Cost: $375

Travel Booking System


scenario-based coding problem on if else with multiple conditions - Travel booking
system
You are tasked with calculating the total cost of a travel package offered by an
agency. The cost varies based on several factors including the destination type,
the season, additional services, and loyalty membership. The base price of the
travel package is $500. Here are the adjustments:

Destination Type:
Domestic: No additional cost
International: +$300

Season:
Peak: +$100
Off-Peak: No additional cost

Additional Services:
Guided Tours: +$150
Luggage Handling: +$50

Loyalty Membership:
Loyalty Member: -$100 discount
Non-Member: No discount

Your goal is to compute the final cost of the package by applying these conditions.

Test Case 1:
Inputs: Destination Type: International
Season: Peak
Guided Tours: Yes
Luggage Handling: Yes
Loyalty Member: Yes

Expected Output: Final Travel Package Cost: $1000

Test Case 2:
Inputs: Destination Type: Domestic
Season: Off-Peak
Guided Tours: No
Luggage Handling: No
Loyalty Member: No

Expected Output: Final Travel Package Cost: $500


To really get the concept of using AND and OR to combine multiple conditions in if
statements, you need to apply them to real-life situations. That’s what these
scenarios are all about—taking something complex and making it practical and
engaging. At Syntax Scenarios, we believe in making coding fun and interactive. By
working through these problems, you’ll improve your coding skills and start
thinking like a programmer.

Parking Fee Calculation


Parking Fee scenario program in python using nested if-else statements
Imagine you’re managing a parking lot, and you need to calculate parking fees based
on the type of vehicle and how long it’s parked. The parking fees differ depending
on whether the vehicle is a car or a motorcycle and how many hours it has been
parked:
For Cars:
If the car is parked for 1 to 3 hours, the fee is $5 per hour.
If the car is parked for more than 3 hours, the fee is reduced to $4 per hour.
For Motorcycles:
If the motorcycle is parked for 1 to 2 hours, the fee is $3 per hour.
If the motorcycle is parked for more than 2 hours, the fee is reduced to $2 per
hour.
For any other vehicle or parking time, the fee is $0.
Test Cases:
Input: Vehicle type: Car, Hours parked: 4
Output: Parking Fee: $16
Input: Vehicle type: Motorcycle, Hours parked: 1
Output: Parking Fee: $3

Car Loan Approval


Car Loan Approval calculator program in python using nested if-else statements
You are working at a bank, and the approval of a car loan depends on the
applicant’s income and credit score:
If the income is above $50,000 and the credit score is above 700, approve the loan.
If the income is between $30,000 and $50,000 and the credit score is between 600
and 700, approve the loan with conditions.
If the income is below $30,000 or the credit score is below 600, reject the loan.
Test Cases:
Input:
Income = $55,000,
Credit Score = 720
Output:
Loan Approval: Approved
Input:
Income = $25,000,
Credit Score = 580 Output:
Loan Approval: Rejected

Exam Eligibility
Attendance checking scenario program image using nested if else in python
A university requires a minimum of 75% attendance to allow students to sit for the
final exam. However, students with attendance between 65% and 74% can attend if
they provide a valid medical certificate. Students with less than 65% attendance
cannot attend the exam.
Attendance >= 75%: Eligible
Attendance between 65% and 74% with a medical certificate: Eligible
Attendance < 65%: Not eligible

Test Case:
Input: 80
Output: Eligible for the exam
Input: 70, Yes (Medical Certificate)
Output: Eligible for the exam

Sports Team Selection


Sports selection scenario program in python using nested if-else statements
You are the head coach for a local sports club, where young athletes come to
develop their skills. It’s your job to place each new player into the appropriate
team for training. The teams are organized by gender and age group to ensure fair
competition and tailored training. The club offers two divisions: Junior teams for
players under 18, and Senior teams for players 18 and older. You need to assign
each player to the correct team based on their gender and age.
If a player is male and under 18, they belong to the “Junior Boys Team.”
If a player is male and 18 or older, they belong to the “Senior Boys Team.”
If a player is female and under 18, they belong to the “Junior Girls Team.”
If a player is female and 18 or older, they belong to the “Senior Girls Team.”
Your task is to automate this process using a program that checks both the gender
and age of the player and assigns them to the appropriate team.

Test Cases:
Input: Gender: Male, Age: 17
Output: Junior Boys Team
Input: Gender: Female, Age: 19
Output: Senior Girls Team
Travel Fare Calculation
Travel fare calculator scenario program image using nested if else in python
You work for a transportation company that offers different travel options: Bus,
Train, Plane, and Car. The fare depends on the type of transport and the distance
traveled. The fare rules are as follows:
Bus: If the distance is more than 50 km, the fare is $15.
Train: If the distance is more than 100 km, the fare is $50.
Plane: If the distance is more than 500 km, the fare is $200.
Car: If the distance is more than 20 km, the fare is $25.
Any other transport-distance combination results in $0 fare.
Your task is to create a program that calculates the fare based on these
conditions.

Test Case:
Input: Transport: Bus, Distance: 60 km
Output: Travel fare: $15
Input: Transport: Train, Distance: 150 km
Output: Travel fare: $50
Input: Transport: Car, Distance: 15 km
Output: Travel fare: $0

Fantasy Character Abilities


Characters abilities fee program using nested if else in python
In a magical kingdom, there are adventurers. Each adventurer has a special ability
that is calculated by their class and experience level. You have been assigned to
create a system that can helps adventurers identify their special abilities before
heading into battle:

If the class is Mage and the experience level is High, the adventurer can cast
Fireball.
If the class is Warrior and the experience level is Medium, the adventurer can
perform Shield Block.
If the class is Rogue and the experience level is Low, the adventurer can use
Stealth.
If the class is Priest and the experience level is High, the adventurer can use
Heal.
For any other class or level combination, the special ability is Unknown Ability.

Test Case:
Input: Class: Mage, Level: High
Output: Special Ability: Fireball
Input: Class: Rogue, Level: Low
Output: Special Ability: Stealth
Input: Class: Warrior, Level: High
Output: Special Ability: Unknown Ability

Magical Creature Identification


Magical creature identification scenario program image using nested if else in
python
In a mystical world, magical creatures are classified based on their habitat and
diet. You are a researcher tasked with identifying these creatures:
If a creature lives in the Forest and is a Herbivore, it is classified as an Elf.
If a creature lives in a Cave and is a Carnivore, it is classified as a Troll.
If a creature lives in the Mountains and is an Omnivore, it is classified as a
Giant.
If a creature lives in the Sea and is an Insectivore, it is classified as a
Mermaid.
For any other habitat and diet combination, the creature is classified as an
Unknown Creature.

Test Cases:
Input: Habitat: Forest, Diet: Herbivore
Output: Creature: Elf
Input: Habitat: Cave, Diet: Carnivore
Output: Creature: Troll
Input: Habitat: Desert, Diet: Herbivore
Output: Creature: Unknown Creature

Travel Package Pricing


Language fee Calculator scenario program image using nested if else in python
You work at a travel agency that offers different travel packages based on where
people want to go and how long they plan to stay. The cost of the travel package
depends on the destination and the length of the trip:
If someone is traveling to Europe and staying between 7 and 14 days, the cost is
$1500.
If they’re going to Asia and staying between 10 and 20 days, the cost is $1200.
If they’re traveling to America and staying between 5 and 10 days, the cost is
$1000.
If the destination is Africa and they’re staying between 14 and 30 days, the cost
is $1800.
For any other combination of destination or duration, we don’t have a price
available, and the system will show a message saying “Price not available.”
Your task is to create a program that helps people find the price of their trip
based on the destination and how many days they plan to stay.

Test Cases:
Input:
Destination: Europe
Duration: 10 days
Output:
Travel Package Price: $1500
Input:
Destination: Asia
Duration: 15 days
Output:
Travel Package Price: $1200

Magical Artifact Quality Check


Artifact quality check program using nested if else in python
You’re working in a magical workshop where they craft mystical artifacts. Each
artifact is made from a certain material and has a specific power level. To make
sure every artifact meets the right standards, you need to classify them based on
these two factors:
If the artifact is made of Gold and has a High power level, it’s classified as
Legendary.
If the artifact is made of Silver and has a Medium power level, it’s classified as
Rare.
If the artifact is made of Bronze and has a Low power level, it’s classified as
Common.
If the artifact is made of Iron and has a Medium power level, it’s classified as
Uncommon.
For any other combination of material and power level, the artifact is classified
as Unknown Quality.
Your job is to write a program that will classify the artifacts based on these
rules.
Test Cases:
Input:
Material: Gold
Power Level: High
Output:
Classification: Legendary
Input:
Material: Silver
Power Level: Medium
Output:
Classification: Rare

Adventure Gear Pricing


Adventure gear calculator scenario program in python using nested if-else
statements
You are managing a store that sells adventure gear to adventurers gearing up for
their next quest. Each type of gear has a specific pricing structure based on the
quantity ordered. Here’s how the pricing works:
If you order a Sword and the quantity is between 3 and 7, the total price is
calculated as quantity * 100 + 50.
If you order a Shield and the quantity is between 2 and 5, the total price is
calculated as quantity * 80 + 30.
If you order a Helmet and the quantity is between 4 and 8, the total price is
calculated as quantity * 60 + 20.
If you order a pair of Boots and the quantity is between 1 and 3, the total price
is calculated as quantity * 40 + 10.
For any other gear type or quantity outside these ranges, the price will be shown
as “Price not available”.
You need to write a program to calculate the total price based on the type of gear
and the quantity ordered.

Test Cases:
Input:
Gear: Sword
Quantity: 5
Output:
Total Price: $550
Input:
Gear: Boots
Quantity: 2
Output:
Total Price: $90
Grocery Bill Calculator
python scenario question: Grocery Bill Calculator: Quick and Easy with Operators!
You’re at a grocery store buying apples, bananas, and oranges. The prices per
kilogram are as follows: apples cost $3, bananas cost $2, and oranges cost $4.
Write a python program to calculate your total bill based on the weight of each
fruit you’re buying.

Test Case
Input:
Enter the weight of apples (kg): 2
Enter the weight of bananas (kg): 1
Enter the weight of oranges (kg): 1.5
Expected Output: Total bill: $14

Movie Ticket Cost


Calculate movie ticket costs scenario question with python operators
You’re going to the movies and need to calculate the total cost of tickets. Each
adult ticket costs $12 and each child ticket costs $8. Write a python program to
calculate the total cost based on the number of adult and child tickets.

Test Case
Input:
Enter the number of adult tickets: 2
Enter the number of child tickets: 3
Expected Output:Total cost: $48

Birthday Party Budget


Calculate your birthday party budget scenario question in python using operators.
You’re organizing a birthday party and need to calculate the total cost of party
items. Each party item costs $4, and you plan to buy 15 items. Write a python
program to compute the total cost of the party items.

Test Case
Input: 15
Expected Output:Total cost: $60.00
Splitting the Bill
Use python operators to split the bill scenario question:.
You and your friends went out to dinner, and the total bill needs to be split
equally among all the diners. Write a python program that asks for the total bill
amount and the number of people. The program should calculate and print the amount
each person needs to pay.

Test Case
Input:
Enter the total bill amount: $150
Enter the total bill amount: $150
Enter the number of people: 5
Expected Output: Each person needs to pay: $30

Calculate Total Monthly Savings


Calculate Monthly Savings in python using Operators scenario question:.
You have multiple sources of income and want to calculate your total savings for
the month after deducting expenses. First, calculate your total income by adding up
the income from different sources. Then, subtract the total expenses from this
total income to determine your monthly savings. Write a python program to perform
these calculations.

Test Case
Input:
Enter the amount of Income 1: $2000
Enter the amount of Income 2: $1500
Enter the amount of Income 3: $800
Enter the total expenses: $2500
Expected Output: Total Monthly Savings: $1800

Fuel Cost Estimator


Calculate fuel costs by applying python operators.
You’re planning a road trip and need to estimate the fuel cost. Write a python
program that asks for the trip’s distance, the car’s fuel efficiency (in kilometers
per liter), and the price of fuel per liter. The program should calculate the total
fuel cost.

Test Case
Input:
Enter the distance of the trip (in km): 300
Enter the fuel efficiency of the car (km per liter): 15
Enter the price of fuel per liter: 2.5
Expected Output: Total fuel cost: $50

Area of a Room
Calculate the area of a room with python operators.
You’re working on a home improvement project and need to calculate the area of a
rectangular room. Write a python program that asks for the length and width of the
room and calculates the area.

Test Case
Input:
Enter the length of the room (in meters): 5
Enter the width of the room (in meters): 4
Expected Output: Area of the room: 20 square meters

Monthly Loan Payment for a New Laptop


Use python operators to figure out monthly loan payments for a new laptop.
Imagine you’ve bought a new laptop for your studies and decided to finance it
through a loan. You need to figure out your monthly payment based on the total
amount of the loan, the monthly interest rate, and the number of months over which
you’ll repay the loan. Use the formula: M=(P×(1+r))/N where M is the monthly
payment, P is the total amount of the loan, r is the monthly interest rate, and N
is the number of months. Write a program in python to calculate this.

Test Case
Input:
Enter the total loan amount for the laptop: $1200
Enter the monthly interest rate (as a decimal): 0.015
Enter the number of months for repayment: 12
Expected Output: Monthly payment: $101.5

Painting a Room
Estimate room painting costs using python operators scenario problem
You’ve decided to paint your bedroom, and you want to calculate the total amount of
paint needed. You know that one can of paint covers a specific area in square feet.
Given the dimensions of your room (length, width, and height) and the area that one
can of paint covers, determine how many cans of paint you need to buy. Assume all
four walls are to be painted and you will not paint the ceiling or the floor. Write
a program in python to perform this calculation.

Test Case
Input:
Enter the length of the room in feet: 12
Enter the width of the room in feet: 10
Enter the height of the room in feet: 8
Enter the coverage area per can in square feet: 350
Expected Output: Cans of paint needed: 1.00571

The Farmer’s Harvest Calculation


Farmer's Harvest Revenue Calculator in python using Operators
A farmer wants to calculate the total revenue from selling his crops: wheat, corn,
and barley. He computes the revenue for each crop by multiplying the amount
harvested by the price per kilogram. After finding the revenue for each type of
crop, he adds them together to get the total revenue. Write a python program to
perform these calculations.

Test Case
Input:
Enter the amount of wheat harvested (in kg): 100
Enter the price per kg of wheat: $2
Enter the amount of corn harvested (in kg): 150
Enter the price per kg of corn: $1.5
Enter the amount of barley harvested (in kg): 200
Enter the price per kg of barley: $1.8
Expected Output:Total Revenue: $785

Space Equipment Purchase


scenario problem in python: Space equipment purchase
You’re preparing for an exciting adventure to a faraway planet, where you need
special equipment to succeed. Each unit you buy has a price, and you know exactly
how many units you need to take. Luckily, the supplier offers a discount of $60.00
for every 5 units you purchase. Before you complete your order, you need to figure
out the total cost after using this discount, ensuring you have everything you need
for the journey without spending too much. Write a python program to calculate the
final cost after applying the discount.

Test Case
Input:
Enter the price per unit: 550
Enter the number of units: 12
Expected Output:
Final cost after discount: $6480

Land Plot Calculator


scenario problem in python: Land plot calculator using operators
Imagine a farmer who wants to divide a big rectangular field into smaller square
plots for planting. The farmer knows the total area of the field and the size of
each square plot. To plan the planting, the farmer needs to find out how many of
these square plots can fit in the field and how much area will be left over. Write
a program in python to help the farmer calculate the number of complete square
plots that can fit and the leftover area.

Test Case
Input:
Enter the total area of the land: 1000
Enter the side length of one square plot: 15
Expected Output:
Number of complete square plots: 4
Remaining area: 100

Digital Clock Seconds Calculation


scenario problem in python time conversion using operators
You have a digital clock that shows hours, minutes, and seconds. Each time you set
the clock, you need to know how many total seconds have passed since midnight.
Write a program in python to convert the given time into the total number of
seconds from the start of the day, making it easier to manage and track time with
your clock.

Test Case
Input:
Enter hours: 2
Enter minutes: 30
Enter seconds: 45
Expected Output:
Total seconds since midnight: 9045

Construction Materials Calculation


scenario problem in python Construction material cost
As a project manager for a large construction site, you need to determine the
amount of cement required to complete the foundation of a building. The foundation
needs a certain volume of concrete to be poured. Each bag of cement contributes a
specific volume to the concrete mix, and you can only order cement in full pallets,
where each pallet contains a fixed number of bags. To meet or exceed the required
concrete volume, you need to calculate how many pallets of cement are necessary.
Additionally, because you can only order full pallets, there will be some excess
concrete due to the rounding up of pallets.
Write a python program to:
1. Calculate the minimum number of pallets needed to meet or exceed the required
volume of concrete.
2. Determine the amount of excess concrete produced due to ordering full pallets.

Test Case
Input:
Enter the required volume of concrete in cubic meters: 1000
Enter the volume contributed by one bag of cement in cubic meters: 2
Enter the number of bags in one pallet: 40
Expected Output:
Total pallets required: 13
Excess concrete produced: 40 cubic meters

Inventory Code Analysis


scenario problem in python: Inventory code analysis
You are working on a system that processes inventory codes, where each code is a
four-digit number used to identify different product categories. Each product gets
a unique four-digit code to help categorize it accurately within the inventory. To
improve the system’s functionality, you need to write a python program. This
program should read a four-digit inventory code from the user, separate the code
into its individual digits, and then display each digit separately. This process
will help in better managing and analyzing the product information.

Test Case
Input:
Enter a four-digit inventory code: 2024
Expected Output:
Digits of the inventory code are:
Thousands place: 2
Hundreds place: 0
Tens place: 2
Ones place: 4

Profit Margin Calculation


scenario problem in python: profit margin calculation
A company sells a product for a certain amount. The costs to make the product and
extra expenses like shipping and taxes are also known. You need to determine the
profit margin percentage, which shows how much profit is made compared to the
selling price. This percentage shows the profit as a part of the selling price.
Write a program in python that takes the selling price, production cost, and
additional expenses as input, and then calculates and displays the profit margin
percentage.

Test Case
Input:
Enter the selling price of the product: 200
Enter the production cost of the product: 120
Enter additional costs (shipping, taxes, etc.): 30
Expected Output:
Profit Margin Percentage: 25%

Subscription Budget Planner


scenario problem in python: Subscription budget planner
You want to enroll in an online course platform that requires a monthly
subscription fee. You have some initial savings set aside and plan to save a fixed
amount each month to cover the subscription cost. To manage your finances
effectively, you want to calculate your total savings after a certain number of
months, determine how many full months of subscriptions you can afford, and find
out how much money will be left after paying for those months. Additionally, you
want to know how much more you need to save to afford another full month of
subscription. This way, you can plan your savings to maintain the subscription as
long as possible and understand what additional savings are required to extend it
further. Write python code to perform these calculations and display the results
based on the inputs for initial savings, monthly savings, subscription fees, and
the number of months you plan to save.

Test Case
Input:
Enter initial savings: 100
Enter monthly savings: 50
Enter monthly subscription fee: 60
Enter the number of months you plan to save: 6
Expected Output:
After 6 months:
Total Savings: 400
Full Months Affordable: 6
Remaining Money: 40
Additional Savings Needed for Next Month: 20

Total Travel Time Calculation


scenario problem in python: Time travel calculation
You are a travel coordinator who needs to prepare a detailed schedule for a
passenger’s trip. The passenger’s journey includes a main flight, a layover, and a
connecting flight. To help the passenger understand how long their entire trip will
take, you need to add up the time of the main flight, the layover, and the
connecting flight. Each part of the trip is given in hours and minutes. Your task
is to write code in python to calculate the total travel time and show it in hours
and minutes.

Test Case
Input:
Enter the main flight duration in hours: 3
Enter the main flight duration in minutes: 45
Enter the layover duration in hours: 2
Enter the layover duration in minutes: 30
Enter the connecting flight duration in hours: 1
Enter the connecting flight duration in minutes: 15
Expected Output:
Total time spent traveling, including layovers and connecting flights, is: 7 hours
and 30 minutes.

Car Loan Plan


scenario problem in python: Car loan plan
You’ve decided to buy your first car and need to take out a loan to finance it. You
have a specific budget in mind for your monthly installment and know the total cost
of the car. You want to calculate how many months it will take to pay off the loan
based on your monthly installment and the interest rate applied to the loan.
Additionally, you want to know the total cost of the loan, including interest.
Write a python program that calculates the number of months required to repay the
loan and the total cost, including the interest.

Test Case
Input:
Car cost: 20000
Down payment: 5000
Interest rate: 5
Monthly installment: 300
Expected Output:
Total loan amount (including interest): 15750
Number of months to pay off the loan: 52.5

Pocket Money Saver


scenario problem in python: Pocket money saver
You receive a base pocket money amount each week, which you enter into the system,
and you have a weekly expense. For the week, a performance multiplier of 1.25 is
applied to your base pocket money. Additionally, if your total savings after
considering the expense exceed $120, you receive a fixed bonus of $30. On the other
hand, if your total savings fall below $60, you face a fixed penalty of $20.
Calculate your total savings after one week. Write a program in python to perform
this calculation.

Test Case
Input:
Enter your base pocket money: $110
Enter your weekly expense: $10
Expected Output: Total savings after one week: $151.875
Using arithmetic operators in scenario-based coding questions in python is an
excellent way to apply your programming skills to real-life situations. Practicing
these scenarios will teach you how to handle various calculations, making your code
more practical and effective. Keep challenging yourself and trying out new ideas to
get better at solving real-life problems.

You might also like