User input in Python is easy + exercises ⌨️

preview_player
Показать описание
#user #input #python
How to accept user input in Python tutorial example explained

00:00:00 user input
00:03:29 #1 mad libs
00:07:10 #2 area calculator
00:09:42 #3 shopping cart
Рекомендации по теме
Комментарии
Автор

#
# EXERCISE 1 MAD LIBS
#
adjective1 = input("Enter an adjective: ")
noun = input("Enter a noun: ")
adjective2 = input("Enter an adjective: ")
verb = input("Enter a verb: ")
adjective3 = input("Enter an adjective: ")

print(f"Today I went to a {adjective1} zoo.")
print(f"In an exhibit, I saw {noun}.")
print(f"{noun} was {adjective2} and {verb}ing.")
print(f"I was {adjective3}!")

#
# EXERCISE 2 AREA CALC
#
length = float(input("Enter the length: "))
width = float(input("Enter the width: "))

#area = length * width
#print(f"The area is: {area}cm^2")

#
# EXERCISE 3 SHOPPING CART
#
item = input("What item would you like to buy?: ")
price = float(input("What is the price?: "))
quantity = int(input("How many would you like?: "))

total = price * quantity

print(f"You have bought {quantity} x {item}/s")
print(f"Your total is: ${round(total, 2)}")

BroCodez
Автор

verb = input ("Enter a verb: ")
noun • input("Enter a noun: ")
adjective • input("Enter an adjective: ")
noun2 • input("Enter another noun: ")
print(f"Today I (verb} with a {noun} during a {adjective] football game")
print(f"I enjoyed it just like I enjoyed my {noun2}.

Output:
Today I fishing with a tree during a hairy football game
I enjoyed it just like I enjoyed my bed

I screwed up my grammar, but thanks for your tutorials Bro Code!!

Tyrese-yv
Автор

"Mark Zuckerberg was berserk and screeching" bro 💀

Cyberbully
Автор

Bro here teaching English too now 🤣

Love you Bro! 😸

felinezero
Автор

noun1 = input("Enter a noun: ")
noun2 = input("Enter another noun: ")
adjective = input("Enter an adjective: ")
verb = input("Enter a verb: ")

print(f"Once there lived a {noun1}.")
print(f"While walking on the road, he/she saw a {adjective} {noun2}, ")
print(f"but the {noun2} was not {adjective}, it {verb}ed on {noun1}")

INPUT:
Enter a noun: Velix
Enter another noun: Hen
Enter an adjective: beautiful
Enter a verb: jump

OUTPUT:
Once there lived a Velix.
While walking on the road, he/she saw a beautiful Hen,
but the Hen was not beautiful, it jumped on Velix.



Bro Code! I luv the series so much! It's easy to understand and I Luv it!

VelixRoblox
Автор

this is the one i did for the area exercise-->
length=int(input("enter an length for rectanlgle:"))
widht=int(input("enter an widht for rectanlgle:"))
area = widht*length
print(f"so the area of the rectangle is according to the measurements u have give is {area}")

thanks for taking a look at this whoever you are
🥰hope u have great day!

FamilyFriendly-zs
Автор

I appreciate your training approach; it's clear, enjoyable, and straightforward. Thank you for keeping it simple and to the point.

joanneosborne
Автор

i = input('what would you like to buy?: ')
p = float(input('how much is it?: '))
q = float(input('how many?: '))
budget = 100
total = p * q
change = budget - total

if total > budget:
print('Your card declined')
else:
print(f'youve bought {q} of {i} for a total of {total}')
print('Thank you for your purchase')
print(f'Your change back is {change}')

Jamfip
Автор

THANKS A LOT FOR THESE EXPLANATIONS AND EXERCISES...THEY ARE DEAD EASY TO UNDERSTAND AND I LOVE THE VIDEOS! LOVE AND TAKE CARE!

francisjacquart
Автор

#2.AREA CALCULATOR
length = int(input("Enter the length of a rectangle: "))
width = int(input("Enter the width of a rectangle: "))
height = int(input("Enter the height of a rectangle: "))

area = length * width
volume = length * width * height

print(f"Area of rectangle is {area}cm^2")
print(f"Volume of rectangle is {volume}cm^3")

Output:
Enter the length of a rectangle: 5
Enter the width of a rectangle: 8
Enter the height of a rectangle: 7
Area of rectangle is 40cm^2
Volume of rectangle is 280cm^3

SonuSah-px
Автор

Why does your output look so simple and the text is green? It's so cool!

tensei_kenkyusha
Автор

Really appreciate coming out learning what I've been wanting to clarify for some time now too! 😂😂 (adjective, noun, verb)

kiiroverse
Автор

This was probably the most vulnerable exercise you made. Anyways, on with the code.

Person = input("Who do you want your person to be?: ")
toy1 = input("Which toy does your person want to play with?: ")
toy2 = input("Which toy does your person also want to play with?: ")



print(f"Once upon a time, there was a boy named {Person}.")
print(f"He liked to play with {toy1} and fiddle with {toy2}")
print(f"All was going well for him, until..")

Who do you want your person to be?: Ballsack
Which toy does your person want to play with?: Water Bottles
Which toy does your person also want to play with?: Call of Duty CD

Once upon a time, there was a boy named Ballsack.
He liked to play with Water Bottles and fiddle with Call of Duty CD
All was going well for him, until..

Wills-igek
Автор

Sir you never disappoint with your content

zephyrgaming
Автор

Mad Libs Game exercise
adjective1 = str(input("Please enter an adjective"))
noun = str(input("Please enter a noun "))
verb = str(input("Please enter a verb "))
adverb = str(input("Please enter an adverb "))
emotion = str(input("Please enter an emotion "))
print(f"Yesterday I went to a {adjective1} city")
print(f"There was a {noun}")
print(f"The {noun} was {verb} {adverb}")
print(f"I was very {emotion}")

Please enter a noun Lion
Please enter a verb Running
Please enter an adverb Aggressively
Please enter an emotion Scared

Yesterday I went to a Confusing city
There was a Lion
The Lion was Running Aggressively
I was very Scared

Thanks for the tutorial!

Kingheart
Автор

I improvised this shopping cart with the if and else statement.

item = input("Enter the product you want to purchase:")
price = float(input("Enter the price of the said product:"))
quantity = int(input("Enter the number of products you wish to purchase:"))

total = price * quantity

print(f"You are about to purchase {quantity} x{item}/s.")
print(f"Thereby, your total is {total} pesos.")
print("Continue to purchase? Type 'yes'")

answer = input("Please type your answer:")

yes = True

if answer := yes:
print(f"You have successfully purchased {quantity} {item}/s. Thank you for your patronage at Yo Mama's store!")
else:
print("Purchase cancelled.")

Thanks!

paradoxine
Автор

Your video is much easier to understand, im learning python to automate things in excell it takes alot of work.

Pgertse
Автор

Enter a noun:Korea
Enter a noun:Stray kids concert
Enter an adjective:Fun
Enter an adjective:Great
Enter a verb:Sing

Yesterday I went to Korea and went to a Stray kids concert.
The Stray kids concert was so Fun.
I was Singing with them.
I really had a Great time with them.

Srinidhiaravind
Автор

adjective1 = input('Enter an adjective: ')
noun = input('Enter a noun: ')
adjective2 = input('Enter a second adjective: ')
verb = input('Enter a verb: ')
adjective3 = input('Enter a third adjective: ')

print(f"Yesterday I went to an {adjective1} house.")
print(f"In a rom, I saw {noun}.")
print(f"{noun} was {adjective2} and {verb}ing.")
print(f"I was {adjective3}!")

Results:
Yesterday I went to an scary house.
In a rom, I saw Jason.
Jason was creepy and hunting.
I was scared!

imperiodosgameplays
Автор

I was about to go to the grocery store, this shopping program might come in handy!

Momo-iquu
join shbcf.ru