Jump to content

Flashcards in php


Lambneck

Recommended Posts

Anyone know how to create a flashcard program?

I have this python one (actually its more like multiple choice questions) but am wondering how to do it in php:

import os, random

count = 0
score = 0

file1 = open('binary.txt', 'r')
file2 = open('decimal.txt', 'r')

f1content = file1.readlines()
f2content = file2.readlines()

while count < 10:
    os.system('clear')

    wordnum = random.randint(0, len(f1content)-1)

    print 'Word:', f1content[wordnum], ''

    options = [random.randint(0, len(f2content)-1),
        random.randint(0, len(f2content)-1),
        random.randint(0, len(f2content)-1)]

    options[random.randint(0, 2)] = wordnum

    print '1 -', f2content[options[0]],
    print '2 -', f2content[options[1]],
    print '3 -', f2content[options[2]],

    answer = input('\nYour choice: ')

    if options[answer-1] == wordnum:
        raw_input('\nCorrect! Hit enter...')
        score = score + 1
    else:
        raw_input('\nWrong! Hit enter...')

    count = count + 1

print '\nYour score is:', score

Link to comment
https://forums.phpfreaks.com/topic/226067-flashcards-in-php/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.