Can you help me with smart parking lot solved question? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

Can you help me with smart parking lot solved question?

I've been stuck on this for 2+ hours so far

31st Jul 2023, 9:35 PM
Kyo
Kyo - avatar
46 Answers
1st Aug 2023, 1:21 AM
Junior
Junior - avatar
+ 4
Share your code
31st Jul 2023, 10:34 PM
Zeusofyogurt
Zeusofyogurt - avatar
+ 4
# Take the number of available spaces as an input spaces = 20 # Display message if spaces are available if spaces > 0: print("Available spaces") # Display a different message if spaces are not available else: print("Sorry, the parking lot is full")
1st Aug 2023, 2:14 PM
𝐀𝐲𝐞𝐬𝐡𝐚 𝐍𝐨𝐨𝐫
𝐀𝐲𝐞𝐬𝐡𝐚 𝐍𝐨𝐨𝐫 - avatar
+ 4
AYESHA NOOR , don't plagiarize the answer/response that is already shared by Kyo. If you have nothing to answer, please don't spam. Shalom Polo, please create your own question and share the code you have created for your project to get further help from the community.
1st Aug 2023, 4:14 PM
D Shah 🎯⏳️
D Shah 🎯⏳️ - avatar
+ 2
Junior, thank you so so much for the help, I used what you told me and it totally worked, and I now understand how it does, thank you
1st Aug 2023, 2:19 PM
Kyo
Kyo - avatar
+ 1
Trist Please share your attempt aswell
31st Jul 2023, 10:10 PM
Junior
Junior - avatar
+ 1
Trist Is this a sololearn challenge by the way? Why are you hard-coding the input? you should probably use input() function i would assume. If there are -spaces that means theres available spaces? That doesnt sound right to me you should probably switch the sign the other way.
31st Jul 2023, 10:33 PM
Junior
Junior - avatar
+ 1
Trist Okay
1st Aug 2023, 12:54 AM
Junior
Junior - avatar
+ 1
okay, thats good. We can also plan out our code using logic like this. Focus on logic and not syntax if your doing pseudocode. ask user for spaces if spaces > 0 print “Available Spaces” else print “Sorry, the parking lot if full”
1st Aug 2023, 1:01 AM
Junior
Junior - avatar
+ 1
Kyo Okay your hard-coding meaning that value isnt changing like a constant. notice the inputs changing? we dont just want the user input to be 20, we want it to be anything. spaces = int(input())
1st Aug 2023, 1:10 AM
Junior
Junior - avatar
+ 1
Kyo Sorry, meant hard-coding a value not hard-coding as in your whole code just that value
1st Aug 2023, 1:14 AM
Junior
Junior - avatar
+ 1
Kyo Yes since you SET the value as 20 any other number is not valid input that you try and put. ONLY 20 is while 0 was another input thats why that error was occuring
1st Aug 2023, 1:16 AM
Junior
Junior - avatar
0
What is the question?
31st Jul 2023, 10:09 PM
Zeusofyogurt
Zeusofyogurt - avatar
0
Ok one sec both of you, I do all of my work on my computer
31st Jul 2023, 10:14 PM
Kyo
Kyo - avatar
0
Ok, so it says "A smart parking lot displays different messages to the visitor based on the number of available spaces." Then it says Task "Complete the program to inform the user about available spaces in the parking lot"
31st Jul 2023, 10:26 PM
Kyo
Kyo - avatar
0
This is what I put # Take the number of available spaces as an input spaces = 20 # Display message if spaces are available if spaces < 0: print("Available spaces") # Display a different message if spaces are not available else: print("Sorry, the parking lot is full")
31st Jul 2023, 10:27 PM
Kyo
Kyo - avatar
0
Seems good enough
31st Jul 2023, 10:29 PM
Zeusofyogurt
Zeusofyogurt - avatar
0
@Junior pls help if you can
31st Jul 2023, 10:29 PM
Kyo
Kyo - avatar
0
Same to the other guy
31st Jul 2023, 10:29 PM
Kyo
Kyo - avatar