#๐Ÿ”’ Pricing System

66 messages ยท Page 1 of 1 (latest)

fleet archBOT
#

@full tinsel

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

full tinsel
#

I'm new to python and I'm having problems with my functions calling at the wrong time and in the wrong order. It's a simple calculator with functions and if else statements. I know there's multiple ways around it but it hasn't clicked yet. displayChoice() and main() both call the same 3 functions. I'm not sure if its a problem with calling the display function in main since they're being used as well as assigned in main or something similar. If you need more context or the rest of the code feel free to dm. I'm sure it's simple but thanks for the help!

#

(forgot to add the attachment oops)

empty bluff
#

it's not an issue to call the function in two places, but it depends on what is your final goal

#

but I don't see what you are trying to do here

#

so you need to explain what you are trying to do and show us the rest of the functions

full tinsel
#

Its a calculator to determine the price for an item in this case a pc with different components and varying prices

empty bluff
#

okay so one issue I see

#

the following functions: [selectStorage, selectGpu, selectRAM] are suppose to return values

#

you try to ask the user to select which one he wants to call inside displayChoice

raw onyx
#

hey

empty bluff
#

yet you are not storing what he write
but then once again you do it inside the main function

#

so why is that?

raw onyx
#

@full tinsel can you send your code as text

#

!code

fleet archBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

lyric panther
# full tinsel

it would be better if you paste your whole code here instead of sending screenshots

raw onyx
#

lol

lyric panther
#

bruh

full tinsel
#

i can't paste the whole things without hitting the character limit hold on

lyric panther
#

that's why you have this

#

!paste

fleet archBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

full tinsel
#

that work?

visual fulcrum
#

yeah it works, but there is an issue with your function calls the options twice when you buy stuff

#
    if display == "S":
        selectStorage()
    if display == "G":
        selectGpu()
    if display == "R":
        selectRAM()
``` this part makes you call for the function, but in the main function, you called the functions again, which made everything repeat twice.

```py
def main():
    # sets base price and calls functions
    displayChoice() #the function shown above^^^
    basePrice = 400
    storageChoice = selectStorage()
    gpuChoice = selectGpu()
    ramChoice = selectRAM()
    calcCostandDisplay(basePrice, storageChoice, gpuChoice, ramChoice)
full tinsel
#

I see

#

I want that function to only choose which option. Lets say "S" and then display options for storage which the user can then choose. Calling them in main was supposed to assign them to 'storageChoice' which is sent along with the others as seen to calculate and display.

visual fulcrum
#

Yeah they are assigned the result of the function, which they later get sent into the calcCostandDisplay function for calculation

visual fulcrum
#

for example, storageChoice = selectStorage()

#

the result of selectStorage() function is automatically saved in storageChoice

#

also, ```py
totalCost = (basePrice + storPrice + gpuPrice + ramPrice)
print("The cost of your custom PC is: ")
print("Storage", storPrice)
print("GPU: ", gpuPrice)
print("RAM:", ramChoice)
print("Total:", totalCost)

main()


you did `print("RAM:", ramChoice)` instead of ramPrice lol
#

oh wait i forgot to ask what's the problem you have

full tinsel
#

Mainly I'm getting issues with the displayChoice function

#

It worked as intended itself but moved on and repeated the same, instead of asking for the next part. then calculating and displaying

visual fulcrum
#

like this?

full tinsel
#

yes.

visual fulcrum
#

yeah this is what I was talking about, it calls the function twice, once in displayChoice and once in main function

full tinsel
#

I want to ask for which option, (H, O, F) store the option and move on to the next part. I'm not sure how to not call it twice if I'm clarifying which part, and also assigning to the choice they made.

visual fulcrum
#

for the displayChoice function, do you want all of those functions to be shown?

visual fulcrum
#

then you have a if statement that checks if the option is not valid, else, return the option

#

this return custChoice saves the option

full tinsel
#

so is the displayChoice function redundant?

visual fulcrum
#

!e

def equation(operator,number):
    total = 0
    if operator == "+":
        total += number
        return total
answer = equation("+",6)
print(answer)
fleet archBOT
#

@visual fulcrum :white_check_mark: Your 3.12 eval job has completed with return code 0.

6
visual fulcrum
#

like removing the functions in the main function

#

then calling all 3 functions on all 3 if statements

#

if option == "S":
storChoice = selectStorage()
GPUChoice = selectGPU
RAMChoice = selectRAM

elif option == "G"
selectGPU
selectStorage
selectRAM
#

prob something like that

visual fulcrum
full tinsel
#

so if they choose "S" for example. I could call the function as well as assign their choice to the argument I send to calculate? instead of calling it in main also

visual fulcrum
#

well if the calculation function is in the main function, it won't receive the variables inside the displayChoice function

#

you would have to include the calculation function in displayChoice function

full tinsel
#

I was abt to ask that. ok i see

visual fulcrum
#

well my suggestion is to remove the if statements in the displayChoice function and just continue the functions in the main loop

#

everything will function ok

full tinsel
#

I need a separate function for displaying, calculating costs, and selecting choices

full tinsel
#

I assigned the choice to the function if the input for display is correct for each function under each if statement. put the calcCost function in the display function, and sent base price as an argument so the casing check function works as well. thanks for the help!

fleet archBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.

#

๐Ÿ”’ Pricing System