## Hardy-Weinberg Problems Tutorial

#### (a computer program written in Q-BASIC and meant to run on IBM compatible computers)

Chip Reynolds
1994 Woodrow Wilson Biology Institute

#### What will the program do?

This program will quiz students on their ability to solve mathematical problems dealing with the Hardy-Weinberg principle. There are 7 basic types of Hardy-Weinberg Problems which are randomly chosen by the program. A student may think that he or she is getting the same problem, but the program does try to 'mix' the 7 problem types and does try to insert different numbers into the problems. The program will keep track of the number of problems attempted, the number of problems missed on the first attempt, and the percentage of problems correctly answered on the first attempt.

#### What doesn't the program do?

The program does not make a hard copy of anything. The program does not permanently save anything. There will be no permanent or retrievable record of how well each student performed on the tutorial.

#### What does the student do?

The student should know the concept of Hardy-Weinberg. The student will sit at the computer with a hand-held calculator and pencil and paper. The student will run the Q-BASIC program. The student will carefully follow the screen directions. The student will be shown 2 sample problems and be asked to answer them. The program will show the student a way to solve each of the 2 sample problems. After the 2 sample problems, the student may start the 7 problem types of the tutorial. The student may quit the tutorial at the completion of any problem. In the event of an incorrect student response, the program will give the student 2 additional 'tries' (a total of 3 attempts) at answering the same question before disclosing the correct numerical response to the student.

#### How does a teacher start the program?

There are 2 methods by which one can start this program. Directions are given for computers with a 3.5" disk drive. However, this program can be made to easily run on computers which do not have that size drive. Perhaps you can ask the knowledgeable computer science person at your school for assistance.

#### METHOD #1

The teacher may type the program, word for word, line for line, punctuation mark for punctuation mark, into the computer. If one chooses to use this method, it is very important that no mistakes are made in typing the program into the computer. In order to type in this program, the following steps must be followed.

1. Turn on the IBM compatible computer. If you are at the C:\> prompt, stay there. If you are in WINDOWS, click on the '-' sign in the upper left hand corner of the PROGRAM MANAGER -[MAIN] screen. Next, move down to the CLOSE choice and click on it. Next, choose to exit the WINDOWS session when given that choice by clicking on OK. The point is, by any means possible to you, mouse or no mouse, get the C:\> prompt on the screen.

2. Once the C:\> prompt is obtained, type in the word QBASIC or qbasic. The QBASIC screen should appear on your monitor. Move to the ESC part of the screen and click on it to clear the first dialog box. Just follow the screen directions to clear the dialog box.

3. A 'clean' screen should now appear on the monitor. Once this clean screen is obtained, the QBASIC program can be typed. Be certain to push the <ENTER> key after typing in each and every numbered line. The more carefully the program is typed in, the more likely it will run without any problems.

4. After the program is typed in, click the cursor on the FILE command in the upper left hand corner of the screen. Select SAVE AS and click on it. At the FILE NAME prompt, type in the word CHIPSTER as the file name. Move to the OK prompt at the bottom of the screen and click on it. The program is now saved to the hard drive (DRIVE C) with the name CHIPSTER.

5. It is recommended that this program also be saved on a 3.5" diskette formatted for the IBM compatible clones. It can also be saved on other sizes of diskettes but those directions will not be given here. To save to a 3.5" IBM formatted disk, you should have just completed steps a, b, c, and d. There are other ways to save it to disk, but they will not be discussed here. Perhaps you can ask the knowledgeable computer science person at your school for assistance. At the completion of step d, the program listing should be on your monitor screen. Click the cursor on the FILE command in the upper left hand corner of the screen. Move to SAVE AS and click on it. Under the DIRS/DRIVES box, there are two little arrows. One moves up and one moves down. Click many times on the down arrow to reach [-A-] and click on it. Then click on OK. On the same screen, at the FILE NAME prompt, type in the name of the program, CHIPSTER, and click on OK. At this point, the program should now be saved on both the hard drive (DRIVE C) and the 3.5" diskette in DRIVE A. When the light is not 'on' near DISK A, remove the diskette from DRIVE A. You may now safely turn off the computer.

6. In order to run the program, perform steps a and b (above). To prevent students from tampering with (changing and invalidating) the program, it is recommended that you keep the program on the 3.5" diskette. Do not allow the students to have access to the diskette. You can load the program from the diskette and then remove the diskette from the computer to protect the diskette.

7. Properly insert the diskette into DRIVE A. Click on the FILE command in the upper left hand corner of the screen. Click on the OPEN option. Under the DIRS/DRIVES box, there are two little arrows. One moves up and one moves down. Click many times on the down arrow and select [-A-], which is DRIVE A, and click on it. Then click on OK. At the FILE listing, move the cursor to CHIPSTER and click on it. Then click on the OK. The program listing for CHIPSTER should appear on the screen.

8. Move the cursor to the RUN command at the top of the screen. Click on the RUN command and then the START command and the program should begin executing.

9. If you would like to return to the WINDOWS screen, first simultaneously press the CTRL and BREAK keys. Then move the cursor to the upper left hand corner of the screen and click on FILE. Choose the EXIT option and click on it. This should present to you the C:\> prompt. At this point, type in the word WIN and then the <ENTER> key. You should now see the familiar WINDOWS on your monitor screen.

#### METHOD #2

Alternatively to METHOD #1, the teacher may send me a blank 3.5" diskette formatted for IBM. I shall load the program on the blank disk and return it. Please be certain to include your return address if you choose to use this method of obtaining this program. My address is given in program lines 40 through 70 in the program listing appearing below this paragraph. Upon receipt of the diskette from me, go to step 'f' in METHOD #1 (above) in order to RUN the program.

#### QBASIC

10 CLS

20 PRINT ' HARDY-WEINBERG PROBLEMS TUTORIAL'

30 PRINT ' written by'

40 PRINT ' Robert W. Reynolds'

50 PRINT ' The Casady Schools'

60 PRINT ' 9500 North Pennsylvania Avenue'

70 PRINT ' Oklahoma City, Oklahoma 73120'

80 PRINT : PRINT : PRINT : PRINT : INPUT 'Push <ENTER> to continue.'; z\$

83 CLS : PRINT : PRINT : PRINT : PRINT

84 PRINT 'Throughout this tutorial, remember to push <ENTER> after'

85 PRINT 'having entered your answer. Also, to leave the program, push'

87 PRINT 'simultaneously the CTRL button and the BREAK button.'

88 PRINT 'Then, choose FILE in the upper left hand corner of the screen and'

89 INPUT 'make the correct choices. Press <ENTER> to continue.'; z\$: CLS

90 PRINT 'Welcome to the HARDY-WEINBERG PROBLEM TUTORIAL. You should'

100 PRINT 'have a pencil and paper and a calculator that can do square root.'

110 PRINT 'You should be quite familiar with the HARDY-WEINBERG equilibrium'

120 PRINT 'concepts and the following HARDY-WEINBERG equations:'

130 PRINT : PRINT 'p + q = 1 and pp + 2pq + qq = 1'

140 PRINT : PRINT : PRINT 'If you do not have a working knowledge of these 2'

160 PRINT 'them. It may be unwise for you to continue this tutorial.'

170 PRINT : PRINT : INPUT 'push <q> to quit or <c> to continue.'; y\$

175 IF y\$ <> 'c' AND y\$ <> 'q' THEN GOTO 170

180 IF y\$ = 'q' THEN CLS : GOTO 10

200 PRINT : PRINT 'If the frequency of a recessive allele in a population is'

210 PRINT '0.16 (or 16%), what is the expected frequency of the dominant'

220 PRINT 'allele?'

230 PRINT : PRINT : INPUT 'Type your answer in decimal format.'; a

240 PRINT : PRINT : IF a <> (.84) THEN PRINT 'Your answer is incorrect.'

245 IF a = (.84) THEN PRINT 'Congratulations.'

250 PRINT : PRINT 'The correct answer is 0.84 (or 84%). Throughout this'

260 PRINT 'tutorial, give the answers in decimal format and not as'

270 PRINT 'percentage. To find the answer, you should have used the'

280 PRINT 'equation: p + q = 1.': PRINT : PRINT

290 PRINT 'From the problem, we know that q = 0.16. From the equation we'

300 PRINT 'know that p + q = 1. By substituting the value of q into the'

310 PRINT 'equation, we arrive at:': PRINT

320 PRINT 'p +( 0.16) = 1. This is equivalent to p = 1 - (0.16) or p = 0.84'

330 PRINT : PRINT : INPUT 'Press <ENTER> enter to continue.'; z\$: CLS

340 PRINT 'Let's try one more sample problem before we start the tutorial'

350 PRINT 'problems.': PRINT : PRINT

360 PRINT 'If the frequency of the homozygous dominant genotype is 0.49'

370 PRINT '(49%) and the frequency of the homozygous recessive genotype'

380 PRINT 'is 0.09 (9%), what is the expected frequency of the heterozygous'

390 PRINT 'genotype?': PRINT : PRINT

420 IF a = .42 THEN PRINT : PRINT 'Congratulations.'

430 PRINT : PRINT 'The correct answer is 0.42 or 42%. Throughout this'

440 PRINT 'tutorial, give the answer in decimal format rather than as a per'

450 PRINT 'centage. To find the answer you should have used the equation:'

460 PRINT : PRINT ' pp + 2pq + qq = 1'

470 PRINT : PRINT : PRINT 'From the problem, we know that pp = 0.49 and that'

480 PRINT 'qq = 0.09. By substituting these 2 values into the equation, we'

490 PRINT 'arrive at:': PRINT ' ( 0.49) + 2pq +( 0.09) = 1'

500 PRINT : PRINT 'Solving for 2pq, which is the frequency of occurrence of'

510 PRINT 'the heterozygous genotype, one can see that:'

520 PRINT : PRINT ' 2pq = 1 - (0.49 + 0.09)'

530 PRINT : PRINT 'Therefore: 2pq = 0.42'

535 INPUT 'Press <ENTER> to continue.'; y\$: CLS

540 PRINT : PRINT 'You have completed the 2 practice problems. If you had'

550 PRINT 'difficulty with the 2 sample problems, you should ask your teacher'

560 PRINT 'for advice on whether to proceed further.': PRINT : PRINT

600 CLS : PRINT 'You are now ready to begin the tutorial. You will not be'

610 PRINT 'given any solutions so be certain to have your calculator and'

620 PRINT 'pencil and paper nearby. Ask your teacher for assistance if you'

640 PRINT : PRINT 'If you wish to quit the program, type <q>.': PRINT

650 INPUT 'To continue the program, type <c>.'; c\$: CLS

660 IF c\$ = 'q' THEN GOTO 10

700 RANDOMIZE TIMER: x = ((INT(RND * 7) + 2) * 1000): n = 0

710 IF w > 0 THEN PRINT : PRINT 'If you wish to quit the program, type <q>.'

720 IF w > 0 THEN INPUT 'To continue the program, type <c>.'; c\$: CLS

730 IF w > 0 AND c\$ = 'q' THEN GOTO 9600

740 w = w + 1: REM w counts number of problems attempted

745 CLS : PRINT 'PROBLEM NUMBER'; w: PRINT : PRINT : PRINT : PRINT

750 IF x = 2000 THEN GOTO 2000

760 IF x = 3000 THEN GOTO 3000

770 IF x = 4000 THEN GOTO 4000

780 IF x = 5000 THEN GOTO 5000

790 IF x = 6000 THEN GOTO 6000

800 IF x = 7000 THEN GOTO 7000

810 IF x = 8000 THEN GOTO 8000

2000 REM: PROBLEM #1

2010 RANDOMIZE TIMER: x% = (INT(RND * 100)): PRINT : PRINT

2020 PRINT 'If the frequency of the dominant allele in a population is';

2030 PRINT x% / 100; ','; 'what is the frequency of the recessive allele in'

2040 INPUT 'the same population'; b: a = ((100 - x%) / 100)

2050 IF b = a THEN GOSUB 9500 ELSE GOSUB 9000

2060 IF n > 0 AND n < 3 THEN GOTO 2020 ELSE GOTO 700

3000 REM PROBLEM #2

3010 RANDOMIZE TIMER: x% = (INT((RND * 9) + 1))

3020 PRINT 'If the frequency of the recessive allele in the gene pool is'

3030 PRINT x% / 10; ', what is the frequency of the homozygous recessive'

3040 INPUT 'genotype in the population'; b: a = (x% / 10) ^ 2

3050 IF b = a THEN GOSUB 9500 ELSE GOSUB 9000

3060 IF n > 0 AND n < 3 THEN GOTO 3020 ELSE GOTO 700

4000 REM:PROBLEM #3

4010 RANDOMIZE TIMER: x% = (INT((RND * 10) + 1) ^ 2)

4020 PRINT 'If the frequency of the homozygous recessive phenotype in'

4030 PRINT 'a population is'; x% / 100; ', what is the frequency of the';

4040 INPUT ' recessive allele in the gene pool of that population'; b

4050 a = (SQR(x% / 100)): IF b = a THEN GOSUB 9500 ELSE GOSUB 9000

4060 IF n > 0 AND n < 3 THEN GOTO 4020 ELSE GOTO 700

5000 REM:PROBLEM #4

5010 RANDOMIZE TIMER: x% = (INT((RND * 10) + 1) ^ 2)

5020 PRINT 'If the frequency of the homozygous recessive phenotype in the'

5030 PRINT 'population is'; x% / 100; ', what is the frequency of the'

5040 INPUT ' dominant allele in the gene pool of that population'; b

5050 a = (1 - (SQR(x% / 100)))

5060 IF b = a THEN GOSUB 9500 ELSE GOSUB 9000

5070 IF n > 0 AND n < 3 THEN GOTO 5020 ELSE GOTO 700

6000 REM:PROBLEM #5

6010 RANDOMIZE TIMER: x% = (INT(RND * 9) + 1)

6020 PRINT 'If the frequency of the dominant allele is found to be'

6030 PRINT x% / 10; ', what is the frequency of the heterozygous genotype in the'

6040 INPUT 'same population'; b: a = 2 * ((x%) * (10 - (x%))) / 100

6050 IF b = a THEN GOSUB 9500 ELSE GOSUB 9000

6060 IF n > 0 AND n < 3 THEN GOTO 6020 ELSE GOTO 700

7000 REM:PROBLEM #6

7010 RANDOMIZE TIMER: x% = (INT((RND * 10) + 1) ^ 2)

7015 RANDOMIZE TIMER: y% = (INT((RND * 10) + 1) ^ 2)

7016 IF ((SQR(x% / 100)) + (SQR(y% / 100))) <> 1 THEN GOTO 7000

7020 PRINT 'If the frequency of the homozygous recessive genotype is'

7030 PRINT x% / 100; 'and the frequency of the homozygous dominant genotype'

7040 PRINT 'is'; y% / 100; ', '; 'what is the predicted frequency of the'

7050 INPUT 'heterozygous genotype in the population'; b

7055 a = (2 * ((SQR(x%)) * (SQR(y%)))) / 100

7060 IF b = a THEN GOSUB 9500 ELSE GOSUB 9000

7070 IF n > 0 AND n < 3 THEN GOTO 7020 ELSE GOTO 700

8000 REM:PROBLEM #7

8010 RANDOMIZE TIMER: x% = (INT((RND * 10) + 1) ^ 2)

8015 IF 2 * (x% / 100) > 1 THEN GOTO 8010

8020 PRINT 'If the frequency of the homozygous dominant genotype and the'

8030 PRINT 'heterozygous genotype are both equal to the same number,'

8040 PRINT x% / 100; ',what is the predicted frequency of the homozygous'

8050 INPUT 'recessive genotype'; b: a = (1 - (2 * x% / 100))

8060 IF b = a THEN GOSUB 9500 ELSE GOSUB 9000

8070 IF n > 0 AND n < 3 THEN GOTO 8020 ELSE GOTO 700

9000 REM:ERROR MESSAGE

9010 CLS : PRINT : PRINT 'You have answered incorrectly. You are given'

9020 PRINT '3 total chances to answer correctly before being given the'

9030 INPUT 'correct answer. Push <ENTER> to continue.'; r: PRINT

9040 n = n + 1: REM counter

9050 IF n = 1 THEN v = v + 1: REM v counts number of first time errors

9060 IF n = 2 THEN PRINT : PRINT 'Only 1 more chance.'

9065 IF n = 3 THEN PRINT 'You have erred on your 3 attempts.'

9070 IF n = 3 THEN PRINT : PRINT 'The correct response is'; a; '.'

9080 IF n = 3 THEN PRINT : PRINT 'Better luck next time.'

9090 PRINT : IF n = 3 OR n = 2 THEN INPUT 'Push <ENTER> to continue.'; r

9100 CLS : RETURN

9500 REM:CONGRATULATORY MESSAGE

9510 n = 0: PRINT : PRINT 'You have answered correctly. Congratulations!'

9520 PRINT : INPUT 'Press <ENTER> to continue.'; r: CLS : RETURN

9600 REM :ENDING MESSAGE

9610 CLS : PRINT 'You have attempted '; w; 'problems. You have missed'

9620 PRINT v; 'of them on the first attempt.': PRINT : PRINT

9630 PRINT 'Your % correct on first attempt was'; ((w - v) / (w)) * 100; '.'

9640 PRINT : INPUT 'press <ENTER> to continue'; i: w = 0: n = 0: GOTO 10

#### Hardy-Weinberg Equilibrium Introduction

The Woodrow Wilson National Fellowship Foundation webmaster@woodrow.org
CN 5281, Princeton NJ 08543-5281 Tel:(609)452-7007 Fax:(609)452-0066