#🔒 Passing variables through parameters

55 messages · Page 1 of 1 (latest)

past fieldBOT
#

@pine ibex

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.

pine ibex
#

why is my post deleted?

#

what

#

anyways

#

I needed some help regarding passing variables through parameters

inland ridge
#

!paste @pine ibex

past fieldBOT
#
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.

topaz lion
pine ibex
#

no

#

uh

#

def menuFeature(stdID):
print("Student Transcript Generation System")
print("==================================================")
print("1. Student Details")
print("2. Statistics")
print("3. Transcript based on major courses")
print("4. Transcript based on minor courses")
print("5. Full Transcript")
print("6. Previous Request")
print("7. Select another student")
print("8. Terminate System")
print("==================================================")
feature_number = int(input("Enter Your Feature: "))
print()

#The print statements will be changed later on
if feature_number == 1:
    detailsFeature(stdID)
elif feature_number == 2:
    statisticsFeature(stdID)
elif feature_number == 3:
    majorTranscriptFeature(stdID)
elif feature_number == 4:
    minorTranscriptFeature(stdID)
elif feature_number == 5:
    fullTranscriptFeature()
elif feature_number == 6:
    previousRequestsFeature(stdID)
elif feature_number == 7:
    newStudentFeature()
elif feature_number == 8:
    terminateFeature()
else:
    print("Invalid feature")

before this code, there's a long ass code of just asking for an ID which is stored in stdID as seen being transferred through parameters so yeah I have these 8 functions and in the last function, which is terminateFeature, it needs to display the total number of times the other 7 functions have been used which will be stored in the requests variable, before exiting, I badly need help in building that🥲

here are the last two codes that needs modification:

def newStudentFeature():

confirm = input("New student entry? Y/N: ").strip().upper()
if confirm == "Y":
    print('\n' * 100)
    main()
else:
    terminateFeature()

def terminateFeature():
print(f"There were {requests} requests made.")
exit()

pine ibex
pine ibex
#

so sorry again for comitting so many mistakes😭im just so stressed out rn..

topaz lion
pine ibex
#

i actually want to send the file cuz i want someone to review my code🙏

pine ibex
pine ibex
topaz lion
pine ibex
#

btw

#

uh

#

mmm

#

lemme try that suggestion

#

the loop one

#

how can I do that + the counter thing

#

thank you so much🙏you're a very good person T^T i cant figure it out myself since im in my first year with no knowledge in python, im just trying to do it myself with self study cuz our teacher doesnt wanna teach us

topaz lion
#

Menu would be basically in a while True
Since the terminate does exit(), you don't even need a break, lol (but you'd normally break in the else and run terminate outside the loop).

Then the counter will be just added any time user selects 1-7
And passed as argument to terminate

pine ibex
#

yea i get that wait lemme uh try that

#

but how about the counter one?

#

how can i put it? like

#

yk

#

OH WAIT

#

WAIT WAIT WAIT

#

I THINK I GOT IT

#

WAIT A SEC

#

lemme try to do it

topaz lion
#

You can increase the counter in each if/elif
Or just add if 0<feature_number<8: and increase the counter

pine ibex
#

oki thank uuu will do

topaz lion
topaz lion
#

Btw did you learn classes?
Because if those things were inside a class, you could use that to keep the counter without using the global keyword

pine ibex
#

yea about that...

#

self study shit

#

cuz our teacher is shit

#

doesnt teach us

#

uh

#

i did this

#
def menuFeature(stdID):
    while True:
        requests = 0
        print("Student Transcript Generation System")
        print("==================================================")
        print("1. Student Details")
        print("2. Statistics")
        print("3. Transcript based on major courses")
        print("4. Transcript based on minor courses")
        print("5. Full Transcript")
        print("6. Previous Request")
        print("7. Select another student")
        print("8. Terminate System")
        print("==================================================")
        feature_number = int(input("Enter Your Feature: "))
        print()

        #The print statements will be changed later on
        if feature_number == 1:
            detailsFeature(stdID)
        elif feature_number == 2:
            statisticsFeature(stdID)
        elif feature_number == 3:
            majorTranscriptFeature(stdID)
        elif feature_number == 4:
            minorTranscriptFeature(stdID)
        elif feature_number == 5:
            fullTranscriptFeature()
        elif feature_number == 6:
            previousRequestsFeature(stdID)
        elif feature_number == 7:
            newStudentFeature(requests)
        elif feature_number == 8:
            terminateFeature(requests)
        else:
            print("Invalid feature")
        requests += 1
pine ibex
#

i'll try to fix it

#

ah just wrong placement of starting value

pulsar pagoda
#

you set it to 0 each loop

past fieldBOT
#
Python help channel closed for inactivity

This help channel has been closed. 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.