मराठी

The ‘Play and learn’ strategy helps toddlers understand concepts in a fun way. Being a senior student you have taken responsibility to develop a program using user-defined - Computer Science (Python)

Advertisements
Advertisements

प्रश्न

The ‘Play and learn’ strategy helps toddlers understand concepts in a fun way. 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 the 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.

थोडक्यात उत्तर

उत्तर

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

#defining options to take input from the user
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)"))
    
    #calling the functions as per the input
    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()

#Defining a function to provide single digit addition with random numbers
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()        

#This function will display the two letter words
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()

#This function will display the three letter words
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()

#This function will display the word with missing character
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()

#This function call will print the options and start the program
options()
shaalaa.com
Types of Module - Built-in Modules
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 7: Functions - Exercise [पृष्ठ १७१]

APPEARS IN

एनसीईआरटी Computer Science [English] Class 11
पाठ 7 Functions
Exercise | Q 3. | पृष्ठ १७१
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×