Support our Blind Hand Charity by donating at 9818291723. Your contribution has the potential to bring about significant positive change for humanity.

Search This Blog

Thursday, December 14, 2023

QUIZ MAKER

EXTRACT ZIP FILE IN PYTHON FOLDER

SAMPLE QUIZ FILE

while True:

    print("""Enter the operation to perform:

1. Create a question bank

2. Answer sample quiz

3. Answer the question bank

4. Quit""")

    o=int(input("Enter the operation number = "))

    if o==4:

        break

    elif o==2:

        s=0

        f1=open('quiz.txt')

        f2=open('quizans.txt')

        fr1=f1.read()

        fr2=f2.read()

        fr2=fr2.split('@')

        t=-1

        for i in fr1.split('$'):

            t+=1

            print(i)

            n=input("Enter option from (a,b,c,d) = ")

            q=0

            if fr2[t]==n:

                    print("-----------")

                    print("CORRECT")

                    print("+4 POINT")

                    s+=4

            else:

                print("-----------")

                print("INCORRECT")

                print("-1 POINT")

                s-=1

        print("Your Percentile =",(s*25/(t+1)),'percentile')

        f1.close()

        f2.close()

    elif o==3:

        qa=input("Enter the question bank file name = ")

        f1=open(qa+'.txt')

        f2=open(qa+'ans.txt')

        fr1=f1.read()

        fr2=f2.read()

        fr2=fr2.split('@')

        t=-1

        s=0

        for i in fr1.split('$'):

            t+=1

            print(i)

            n=input("Enter option from (a,b,c,d) = ")

            if fr2[t]==n:

                print("-----------")

                print("CORRECT")

                print("+4 POINT")

                s+=4

            else:

                print("-----------")

                print("INCORRECT")

                print("-1 POINT")

                s-=1

        print("Your Percentile =",(s*25/(t+1)),'percentile')

        f1.close()

        f2.close()

            

    elif o==1:

        r=input("Enter the file name = ")

        f1=open(r+'.txt','a')

        f2=open(r+'ans.txt','a')

        s=0

        p=['[a].','[b].','[c].','[d].']

        while True:

            s+=1

            q=input("Enter the question or run to exit = ")

            if q.lower()=='run':

                break

            f1.write(str(s))

            f1.write('.')

            f1.write(q)

            f1.write('\n')

            for i in range(0,4):

                a=input("Enter option = ")

                f1.write(p[i])

                f1.write(a)

                f1.write('\n')

            ans=input("Enter the option of correct ans = ")

            f2.write(ans)

            f1.write('$')

            f1.write('\n')

            f2.write('@')

        f1.close()

        f2.close()

OUTPUT