Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TUTORIAL: My First Project Quiz In Python Programming
#1
class Babalola:
def __init__(self):
self.__error_count = self.__total_count = 0
print("+---------------------------------+")
print("| Quiz ")
print("+----------------------------------+")
def check_equals(self, msg, expected, actual):
print("[", msg, "] ")
self.__total_count += 1 # Count this test
if expected == actual:
print("Correct")
else:
self.__error_count += 1 # Count this failed test
print("*** Failed ! Expected:", expected, " actual:", actual)
def report_results(self):
print("+--------------------------------------")
print("|", self.__total_count, "tests run")
print("|", self.__total_count -self.__error_count, " passed")
print("|", self.__error_count, " failed")
print("| you get ",(self.__total_count -self.__error_count)/(self.__total_count)*(100),"% Correctly")
print("+--------------------------------------")


i
saved it as Musa.py and import the class

from musa import Babalola


def main():
t=Babalola()

a=int(input("what is the square root of 64:"))
t.check_equals("Question 1",8,a)

b=int(input("what is 10×4 =:"))
t.check_equals("Question 2",40,b)

c=input("what is the output of print str[2:] if str=\'Babalola\':")
t.check_equals("Question 3","balola",c)

d=int(input(" What is the output of len([1, 2, 3])?:"))
t.check_equals("Question 4",3,d)

e=int(input("What is the output of 5×(7%3):"))
t.check_equals("Question 5",5,e)

t.report_results()
main()


@dealwap


Possibly Related Threads...
Thread Author Replies Views Last Post
  FUN: Rhombus With Python Mbabalawlar 0 88 01-06-2018, 10:00 PM
Last Post: Mbabalawlar
  FUN: Love Calculator With Python Mbabalawlar 0 118 01-06-2018, 09:56 PM
Last Post: Mbabalawlar
  SHARED: Why Learn Python? cheatex 5 456 04-27-2017, 08:54 PM
Last Post: devHammed
  Creating A Simple Random Username And Password Generator With Python Jolliano 4 688 01-01-2017, 10:58 PM
Last Post: Jolliano
  Python Program To Solve Quadratic Equation dealwap 4 664 12-10-2016, 08:43 AM
Last Post: dealwap
  Awesome Python Tricks A Beginner Should Know smartlord 8 718 12-04-2016, 01:48 PM
Last Post: Ahkohd
  How To Validate User's Input In Python Ahkohd 1 308 12-03-2016, 12:39 PM
Last Post: dealwap
  Check If A Variable Is Defined Or Not In Python Ahkohd 0 260 12-03-2016, 09:42 AM
Last Post: Ahkohd
  Why You Should Learn Python As Your First Programming Language dealwap 0 353 11-04-2016, 07:37 AM
Last Post: dealwap
  Learn Python From Scratch Here On Nct dealwap 8 835 11-02-2016, 04:50 PM
Last Post: Sakpobi Maro



Users browsing this thread: 1 Guest(s)

About Nigeria's Creative Talents

Nigeria's Creative Talents is an online community where every creative Nigerians can share ideas with themselves.

For any more information, please use our contact form.

              User Links

              Advertise