I wish did fix the issue. Here's an example of what I mentioned in the comments. It builds a list of the desired number of operations in equal quantities, then shows how to pull a random one from that list: Public Class Form1
Private Operations As New List(Of String)
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Operations = CreateOperations(10)
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
If Operations.Count > 0 Then
Dim operation As String = NextRandomOperation()
Debug.Print(operation)
Else
Debug.Print("No more operations in list!")
End If
End Sub
Private Function CreateOperations(ByVal NumberOperations As Integer) As List(Of String)
Dim operators() As String = {"+", "", "X"}
Dim operations As New List(Of String)
While Operations.Count < NumberOperations
Operations.AddRange(operators)
End While
While Operations.Count > NumberOperations
Operations.RemoveAt(Operations.Count  1)
End While
Return operations
End Function
Private Function NextRandomOperation() As String
Static R As New Random
If Operations.Count > 0 Then
Dim index As Integer = R.Next(Operations.Count)
Dim operation As String = Operations(index)
Operations.RemoveAt(index)
Return operation
End If
Return ""
End Function
End Class
Boards Message : 
You Must Login
Or Sign Up
to Add Your Comments . 
Share :

How can I randomly choose a maths operator and ask recurring maths questions with it?
Date : March 29 2020, 07:55 AM
hope this fix your issue There is a function in Python called eval() that evaluates strings which contain mathematical expressions. import random
ops = ['+', '', '*', '/']
num1 = random.randint(0,12)
num2 = random.randint(0,10)
operation = random.choice(ops)
print(num1)
print(num2)
print(operation)
maths = eval(str(num1) + operation + str(num2))
print(maths)

Generating Maths quiz by JQuery
Date : March 29 2020, 07:55 AM
This might help you I am tasked to edit an external javascript file for a basic Maths quiz for my schoolwork (not allowed to touch the html and the css). I'm very new to programming, and have attempted the question, but it doesn't work. I need some help here, so thanks in advance. , This is the complete substitute for your javascript code. $(document).ready(function(){
$('input[type="button"]').click(function(){
//alert box feedback before generating random numbers
var num1=parseInt($("#number1").text());
var num2=parseInt($("#number2").text());
var total = num1 + num2;
var answer = parseInt($("input[type='text']").val());
if ($("input[type='text']").val() === '') {
alert("You have not key in any answer");
} else if (answer === total) {
alert("You have key in the right answer");
} else {
alert("You have key in the wrong answer");
}
//generate a random number range 1 to 9 for number 1 after clicking alert box using callback function
$("#number1").innerHTML =
Math.floor(Math.random() * 10);
//generate a random number range 1 to 9 for number 2 after clicking alert box using callback function
$("#number2").innerHTML =
Math.floor(Math.random() * 10);
});
});

VB  Maths Quiz Check Answer
Tag : vb.net , By : Gilmar Souza Jr.
Date : March 29 2020, 07:55 AM
around this issue I am currently doing a project and am trying to make my own maths quiz. Basically, I have 3 labels and a textbox. In the first and third label a number is randomly generated. In the second label, a mathematical operator is selected (either +,  or รท). In the textbox, the user will input an answer to the equation, which brings me to the question i would like to ask: , Perhaps this will help. Given these functions: Dim dictionary = New Dictionary(Of String, Func(Of Double, Double, Double))() _
From _
{ _
{"+", Function(x, y) x + y}, _
{"", Function(x, y) x  y}, _
{"*", Function(x, y) x * y}, _
{"/", Function(x, y) x / y} _
}
Dim process As Func(Of String, String, String, Double) = _
Function(op, x, y) _
dictionary(op)(Double.Parse(x), Double.Parse(y))
Dim operator = TextBox1.Text ' "+"
Dim num1 = TextBox2.Text ' "5"
Dim num2 = TextBox3.Text ' "4"
Dim result = process(operator, num1, num2) ' 9

Maths Quiz Task Python
Tag : python , By : desmiserables
Date : March 29 2020, 07:55 AM
will be helpful for those in need You're close... you just need to move the positioning of your loop a little bit so that it catches the actual asking of the question. As it stands now, you're only looping over the part where you generate the questions. from random import randint
while True:
correct = 0
userrange = int(input("How many questions would you like?\n"))
difficulty = input("Choose your difficulty: beginner, intermediate or advanced?\n")
if difficulty == "beginner":
no = 10
if difficulty == "intermediate":
no = 25
if difficulty == "advanced":
no = 100
qtype = input("Would you like to do addition, subtraction or multiplication?\n")
for i in range(userrange): # Move the loop to start here, instead of under each if / elif
n1 = randint(1, no) # We can go ahead and generate our random numbers here also
n2 = randint(1, no)
if qtype == "addition":
prod = n1 + n2
lo = "plus"
elif qtype == "subtraction":
prod = n1  n2
lo = "minus"
elif qtype == "multiplication":
prod = n1 * n2
lo = "times"
ans = int(input("What's %d %s %d?" % (n1 ,lo ,n2))) # We also need to move the question into the loop, so that it is asked each time
if ans == prod:
print ("That's right  well done.\n")
correct = correct + 1
else:
print ("No, I'm afraid the answer is %d.\n" % prod)
print ("\nI asked you %d questions. You got %d of them right." %(userrange, correct))
if correct >= (userrange%3)*2:
print ("Well done!")
elif (userrange%3) < correct < (userrange%3)*2:
print ("You need more practice")
else:
print ("Please ask your maths teacher for help!")
try_again = int(input("\nPress 1 to try again, press 0 to exit.\n "))
if try_again == 0:
break

PHP simple maths quiz program
Date : March 29 2020, 07:55 AM

