Simple technology quiz

General Tech Technology & Software 2 years ago

0 2 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Technology & Software related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (2)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago


This is my first program that uses more than just boring ol' if/else statements - I made a whole 246 line game that's still a work in progress simply using if/else - and I'm going to email this to my teacher later tonight.

Please suggest more things I can add and report any bugs (although I've found none so far).

# Starting points value
points = 0

# correct() calls this
def correct():
    global points
    points = points + 1
    print("Correct!")
    print("You have",points,"points!")
    a = input()

# incorrect() calls this
def incorrect():
    print("Incorrect!")
    ab = input()


print("Welcome to this five question general IT quiz!")
print("If you're stuck and need help, type 'Hint'!")
a = input()

# Question 1

print("Question one:")
q1 = input("What does LAN stand for?")

if q1 == "Hint":
   print("The N stands for network...")
   q1 = input("What does LAN stand for?")

elif q1 == "hint":
    print("The N stands for network...")
    q1 = input("What does LAN stand for?")

if q1 == "Local Area Network":
    correct()

elif q1 == "local area network":
    correct()

elif q1 == "Local area network":
    correct()

elif q1 == "Local area Network":
    correct()

else:
    incorrect()

# Question 2

print("Question 2:")
print("Fill in the blank.")
q2 = input("A monitor is an example of an ------ device.")

if q2 == "Hint":
    print("Another example would be speakers or headphones.")
    q2 = input("A monitor is an example of an ------ device.")

elif q2 == "hint":
    print("Another example would be speakers or headphones.")
    q2 = input("A monitor is an example of an ------ device.")

if q2 == "Output":
    correct()

elif q2 == "output":
    correct()

else:
    incorrect()

# Question 3

print("Question 3:")
q3 = input("True or false: To connect to the internet, you MUST have an ethernet cable connected from your router to your PC.")

if q3 == "Hint":
    print("Remember, there are two types of internet connecttion.")
    q3 = input("True or false: To connect to the internet, you MUST have an ethernet cable connected from your router to your PC.")

elif q3 == "hint":
    print
                                                
                                                
0 views
0 shares
profilepic.png
manpreet 2 years ago

First, you can't possibly check for all possible uppercase/lowercase combinations of the answers, and it is looking messy even as it currently is. This is the perfect place to convert the input to lowercase like this:

q1 = input("What does LAN stand for?").lower()

Now, all you need to do is check for "hint" and "local area network" for question one:

if q1 == "hint":
    print("The N stands for network...")
    q1 = input("What does LAN stand for?").lower()

if q1 == "local area network":
    correct()

else:
    incorrect()

In question five, you have multiple inputs. Why don't you handle it like this instead of having multiple if/elif/else statements?

if q5 == "hint":
    print("A better one of these will boost grapical performance and framerate in games.")
    q5 = input("Radeon, EVGA, XFX and Sapphire are companies that make what computer component?").lower()

if s in ['gpu', 'gpus', 'graphics card', 'graphics cards']:
    correct()

else:
    incorrect()

In this print call, you should put spaces around your string literals and variables to make it easier to read:

print("You have",points,"points!")

q1 isn't a very descriptive variable name, and it does not hold the question, as it suggests. Also, why are you using one variable name for each question? This code can be cleaned up a lot by creating a method to administer the questions:

def administer_question(question, answers, hint):

    while True:
        user_answer = input(question)

        if user_answer == "hint":
            print(hint)
        elif user_answer in answers:
            correct()
            return
        else:
            incorrect()
            return

Now, the user can input "hint" as many times as they wish.

This is called as:

administer_question("Radeon, EVGA, XFX and Sapphire are companies that make what computer component?",
                    ["gpu", "gpus", "graphics card", "graphics cards"],
                    "A better one of these will boost graphical performance and frame rate in games.")

I would pass a string to the incorrect() function to display the correct answer to the user:

def incorrect(correct_answer):
    print("Incorrect!")
    print("The correct answer is '", correct_answer, "'")
    pause = input()

Note also that I renamed the variable ab to pause so it demonstrates better that the program is just waiting for the user to input a value to continue. However, with all these pauses for input, maybe you should explain that to the user so they don't wait for the program to respond and wonder what is going on.


0 views   0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.