#๐Ÿ”’ Random question number setter doesnt work

35 messages ยท Page 1 of 1 (latest)

cinder craterBOT
#

@mossy vortex

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.

mossy vortex
#

for ques in range (1, questions_count +1):
print("Current score:" + str(score))
print("Question " + str(ques)+ " of " + str(questions_count))

if ques == questions_count:
    print("Challenge question!")
    # Challenge now also respects difficulty range
    question_text = create_question(min_num, max_num)
else:
    question_text = create_question(min_num, max_num)

correct, time_taken = ask_question(question_text)
if correct:
    if ques == questions_count:
        points = max(20 - time_taken, 1)
    else:
        points= max(10 - time_taken, 1)
    score += points
    correct_answers += 1
    print("Correct! You took" ,time_taken, "seconds and earned",points, "points")
else:
    points = 0
    print("Incorrect! You took",time_taken, "seconds and earned",points, "points")
results.append((question_text, correct, time_taken, points))
print("Final score: "+ str(score))
print("Total correct answers: " +str(correct_answers))

total_questions =len(results)
total_time_taken = sum([entry[2] for entry in results])
average_time = round(total_time_taken / total_questions)
percentage = round((correct_answers / total_questions) *100)
print("\nTEST RESULTS")
print("Final score",score)
print("Correct answer rate:", percentage, "%")
print("Average reponse time:", average_time,"s")

print("Question\tCorrect\tTime")
question_number = 1
for entry in results:
if entry[1]:
correct_str = "Yes"
else:
correct_str= "No"
print(question_number,"\t\t", correct_str + "\t" + str(entry[2]), "s")
question_number +=1

cinder craterBOT
#

Hey @mossy vortex!

Please edit your message to use a code block

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

This will result in the following:

print('Hello, world!')```
raw oracle
#

And what's actually happening?

#

Also, the three backticks need to be on their own line

mossy vortex
# raw oracle And what's actually happening?

so basically in this code, if easy is selected its supposed to set the minimum ammount of questions generated as 5, the max is 10, medium is supposed to be between 10 and 20, hard is between 15 and 50

mossy vortex
raw oracle
#

What's your question?

mossy vortex
#

like for some reason its not generating a random ammount of questions

raw oracle
#

You don't seem to ever call the functions.

mossy vortex
#

it always 5-10 for easy, 1-10 for medium and 1-15 for hard

raw oracle
#

Oh, nvm, the second code is different

sour pine
#

!pastebin

cinder craterBOT
#
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.

sour pine
#

can u shove ur entire code here btw please

mossy vortex
raw oracle
#

You need to paste the link here

sour pine
raw oracle
#

There doesn't seem to be any code here that attempts to generate a random number of questions.

#
for ques in range (1, questions_count +1):
mossy vortex
#

how do i fix it ive been like trying to find a fix it since yesterday ๐Ÿ˜ญ

raw oracle
#

You appear to know how to generate a random number already.

mossy vortex
#

how do i get it to generate a number inbetween set numbers, depeneding on wether the user selected easy, medium or hard

#

thats the hard bit

raw oracle
#

You're setting questions_count already depending on the difficulty.

mossy vortex
#

i fixed it

#

thank yall so much <333

cinder craterBOT
#
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.