Computer Assignment3
Computer Assignment3
Being
a senior student you have taken responsibility to develop a program using user
defined functions to help children master two and three-letter words using English
alphabets and addition of single digit numbers. Make sure that you perform a
careful analysis of the type of questions that can be included as per the age and
curriculum.
ANSWER:
This program can be implemented in many ways. The structure will depend on the type of questions and
options provided. A basic structure to start the program is given below. It can be built into a more
complex program as per the options and type of questions to be included.
PROGRAM:
import random
def options():
print("\n\nWhat would you like to practice today?")
print("1. Addition")
print("2. Two(2) letters words")
print("3. Three(3) letter words")
print("4. Word Substitution")
print("5. Exit")
inp=int(input("Enter your choice(1-5)"))
if inp == 1:
sumOfDigit()
elif inp == 2:
twoLetterWords()
elif inp == 3:
threeLetterWords()
elif inp == 4:
wordSubstitution()
elif inp == 5:
return
else:
print("Invalid Input. Please try again\n")
options()
def sumOfDigit():
x = random.randint(1,9)
y = random.randint(1,9)
print("What will be the sum of",x,"and",y,"? ")
z = int(input())
if(z == (x+y)):
print("Congratulation...Correct Answer...\n")
a = input("Do you want to try again(Y/N)? ")
if a == "n" or a == "N":
options()
else:
sumOfDigit()
else:
print("Oops!!! Wrong Answer...\n")
a = input("Do you want to try again(Y/N)? ")
if a == "n" or a == "N":
options()
else:
sumOfDigit()
def twoLetterWords():
words = ["up","if","is","my","no"]
i=0
while i < len(words):
print("\n\nNew Word: ",words[i])
i += 1
inp = input("\n\nContinue(Y/N):")
if(inp == "n" or inp == "N"):
break;
options()
def threeLetterWords():
words = ["bad","cup","hat","cub","rat"]
i=0
while i < len(words):
print("\n\nNew Word: ",words[i])
i += 1
inp = input("Continue(Y/N):")
if(inp == "n" or inp == "N"):
break;
options()
def wordSubstitution():
words = ["b_d","c_p","_at","c_b","_at"]
ans = ["a","u","h","u","r"]
i=0
while i < len(words):
print("\n\nWhat is the missing letter: ",words[i])
x = input()
if(x == ans[i]):
print("Congratulation...Correct Answer...\n")
else:
print("Oops!!!Wrong Answer...\n")
i += 1
inp = input("Continue(Y/N):")
if(inp == "n" or inp == "N"):
break;
options()
options()
OUTPUT: