Pop Quiz: Math and Geography
1. Is x a multiple of y? Each variable will be selected randomly from a number between 1-100.
! You are asking the question twice and the first time the values of x and y are not determined, so no answer can
be given. Remove the first InputString. The value of r isn’t a string. To give an answer that can be graded, you
would have to enter True or False, not true or false.
In[255]:= InputString["Is " <> ToString[x] <> " a multiple of " <> ToString[y] <> " ?",
"Type true or false here"]
{x, y} = RandomInteger[{1, 100}, 2];
r = Input["Is " <> ToString[x] <> " a multiple of " ToString[y] <> "?"]
If [r ⩵ Divisible[x, y] → true, "Correct!", "No, r==Divisible[x,y]-−>false"]
Out[255]= True
Out[257]= No
Out[258]= If[No # False → true, Correct!, No, r==Divisible[x,y]-−>false]
myPathName = "/∕Users/∕Alexis_Ploss/∕Desktop/∕";
data = Import[FileNameJoin[{myPathName, "States.csv"}]];
2. What is the capital of the following randomly selected state?
In[267]:= ask = RandomChoice[data[[All, 1]]];
r = InputString["What is the capital of " <> ask <> "?"]
If[StringMatchQ[r, capital[ask], IgnoreCase → True], "Correct!",
"Incorrect, the " <> capital[ask] <> " is the capital of " <> ask <> "."]
Out[268]= Richmond
Out[269]= Correct!
3. What is the largest city of the following randomly selected state?
! One problem is with the highlighted line.
ask = RandomChoice[data[[All, 1]]]; others = RandomSample[data[[All, 4]], {ask}],
3; choices = Map[mostpopulouscity, Join[{ask}, others]] /∕/∕ RandomSample;
key = Association @@ Map[#[[1]] → #[[4]] &, Transpose[{choices, {"a", "b", "c", "d"}}]];
Print[key];
{ask, choices}
r = InputString["The most populous city of " <> ask <> " is:n" <>
Inner["n" <> #1 <> "-−" <> #2 &, {"a", "b", "c", "d"}, choices, StringJoin]];
Syntax::tsntxi :
"ask = RandomChoice[data[[All, 1]]]; others = RandomSample[data[[All, 4]], {ask}], ,1-" is incomplete;
more input is needed.

More Related Content

PDF
{shiny}と{leaflet}による地図アプリ開発Tips
PPTX
Open course(programming languages) 20150121
PDF
Cooling Project for Students- Answer Key
PDF
Cooling Project Data
PDF
Final Project
PDF
Cooling Project Experiment
PDF
Project 1
PDF
MATLAB Final Project
{shiny}と{leaflet}による地図アプリ開発Tips
Open course(programming languages) 20150121
Cooling Project for Students- Answer Key
Cooling Project Data
Final Project
Cooling Project Experiment
Project 1
MATLAB Final Project

Similar to Pop Quiz.nb (1) (6)

PDF
Gareth hayes. non alphanumeric javascript-php and shared fuzzing
PDF
Get started with Reason
PDF
Quill + Spark = Better Together
PDF
11 1. multi-dimensional array eng
PDF
C# using Visual studio - Windows Form. If possible step-by-step inst.pdf
PDF
Hitchhiker's Guide to Functional Programming
Gareth hayes. non alphanumeric javascript-php and shared fuzzing
Get started with Reason
Quill + Spark = Better Together
11 1. multi-dimensional array eng
C# using Visual studio - Windows Form. If possible step-by-step inst.pdf
Hitchhiker's Guide to Functional Programming
Ad

Pop Quiz.nb (1)

  • 1. Pop Quiz: Math and Geography 1. Is x a multiple of y? Each variable will be selected randomly from a number between 1-100. ! You are asking the question twice and the first time the values of x and y are not determined, so no answer can be given. Remove the first InputString. The value of r isn’t a string. To give an answer that can be graded, you would have to enter True or False, not true or false. In[255]:= InputString["Is " <> ToString[x] <> " a multiple of " <> ToString[y] <> " ?", "Type true or false here"] {x, y} = RandomInteger[{1, 100}, 2]; r = Input["Is " <> ToString[x] <> " a multiple of " ToString[y] <> "?"] If [r ⩵ Divisible[x, y] → true, "Correct!", "No, r==Divisible[x,y]-−>false"] Out[255]= True Out[257]= No Out[258]= If[No # False → true, Correct!, No, r==Divisible[x,y]-−>false] myPathName = "/∕Users/∕Alexis_Ploss/∕Desktop/∕"; data = Import[FileNameJoin[{myPathName, "States.csv"}]]; 2. What is the capital of the following randomly selected state? In[267]:= ask = RandomChoice[data[[All, 1]]]; r = InputString["What is the capital of " <> ask <> "?"] If[StringMatchQ[r, capital[ask], IgnoreCase → True], "Correct!", "Incorrect, the " <> capital[ask] <> " is the capital of " <> ask <> "."] Out[268]= Richmond Out[269]= Correct! 3. What is the largest city of the following randomly selected state? ! One problem is with the highlighted line. ask = RandomChoice[data[[All, 1]]]; others = RandomSample[data[[All, 4]], {ask}], 3; choices = Map[mostpopulouscity, Join[{ask}, others]] /∕/∕ RandomSample; key = Association @@ Map[#[[1]] → #[[4]] &, Transpose[{choices, {"a", "b", "c", "d"}}]]; Print[key]; {ask, choices} r = InputString["The most populous city of " <> ask <> " is:n" <> Inner["n" <> #1 <> "-−" <> #2 &, {"a", "b", "c", "d"}, choices, StringJoin]]; Syntax::tsntxi : "ask = RandomChoice[data[[All, 1]]]; others = RandomSample[data[[All, 4]], {ask}], ,1-" is incomplete; more input is needed.