BA-GROUP-ASSIGNMENT / Solution

0 stars 1 forks source link

Practical Solution #8

Open I-JOSIANE-JOHNGWA opened 1 year ago

215192672 commented 1 year ago

Import pyttsx3

Initialize text-to-speech engine

Tts_engine = pyttsx3.init()

Def ask_for_id(): Tts_engine.say(“Please enter your ID.”) Tts_engine.runAndWait()

# Assume the learner’s ID is provided as text input
Learner_id = input(“Enter your ID: “)

Tts_engine.say(f”Thank you for providing your ID, {learner_id}.”)
Tts_engine.runAndWait()

Def ask_preference(): Tts_engine.say(“Would you like a summary or an explanation of the topic?”) Tts_engine.runAndWait()

While True:
    User_input = input(“Summary or Whole Topic: “)
    If user_input:
        If “summary” in user_input.lower():
            # Provide a summary
            Summary = summarize_vector_quantity()
            Tts_engine.say(“I’m here to assist, not to imply superiority over the teacher. Let me provide a summary:”)
            Tts_engine.say(summary)
            Tts_engine.runAndWait()
        Elif “whole topic” in user_input.lower():
            # Explain the topic
            Explanation = explain_vector_quantity()
            Tts_engine.say(“I’m here to assist, not to imply superiority over the teacher. Let me explain the whole topic:”)
            Tts_engine.say(explanation)
            Tts_engine.runAndWait()
        Else:
            Tts_engine.say(“I’m sorry, I didn’t understand your choice. Please say ‘summary’ or ‘whole topic’.”)
            Tts_engine.runAndWait()
        Break

Def summarize_vector_quantity(): Summary = “””A vector quantity is a physical quantity that has both magnitude and direction. It is represented by an arrow, where the length of the arrow represents the magnitude of the quantity, And the direction of the arrow indicates the direction in which the quantity is acting. Common examples of vector quantities include displacement, velocity, force, and acceleration.””” Return summary

Def explain_vector_quantity(): Explanation = “””In Grade 12 Physical Sciences, vector quantities are a fundamental concept. They are used to describe quantities in the physical world that have both a size (magnitude) And a direction. Let’s break down the key points:

  1. Magnitude: Magnitude refers to the size or amount of the quantity being described. For example, if we are talking about velocity, the magnitude would be the speed of an object.

  2. Direction: Direction indicates where the vector is pointing or acting. It’s essential to specify direction when dealing with vector quantities. In many cases, directions are described using angles or reference axes, such as north, east, south, and west.

  3. Representation: Vectors are often represented graphically as arrows. The length of the arrow represents the magnitude, and the orientation of the arrow indicates the direction. Mathematicians and physicists use vector notation to represent these quantities mathematically.

                 4. **Examples**: Vector quantities are prevalent in physics. Here are a few examples:
                    - Displacement: Describes the change in position of an object.
                    - Velocity: Represents the rate of change of an object’s position, including both speed and direction.
                    - Force: Defines a push or pull on an object, with both magnitude and direction.
                    - Acceleration: Represents the change in velocity over time.
  4. Operations: Vectors can be added, subtracted, and multiplied by scalars (quantities without direction) To perform various calculations. These operations are crucial for solving problems in physics and engineering.

                 Understanding vector quantities is essential in various fields of science and engineering, 
                 As they provide a powerful way to describe real-world phenomena accurately. Whether you’re calculating 
                 The trajectory of a projectile, analyzing forces in a mechanical system, or studying the motion of celestial bodies, 
                 Vectors play a central role in modeling and understanding physical phenomena.”””

    Return explanation

def ask_understanding(): Tts_engine.say(“Did you understand the explanation? Please enter ‘yes’ or ‘no’.”) Tts_engine.runAndWait()

While True:
    User_input = input(“Did you understand? (yes/no): “)
    If user_input:
        If “yes” in user_input.lower():
            Tts_engine.say(“Thank you for your understanding. If you have more questions or need further explanations, don’t hesitate to consult with me.”)
            Tts_engine.runAndWait()
        Elif “no” in user_input.lower():
            Tts_engine.say(“That’s perfectly okay. I don’t mind explaining again. Please feel free to ask if you have any questions.”)
            Tts_engine.runAndWait()
        Else:
            Tts_engine.say(“I’m sorry, I didn’t understand your response. Please say ‘yes’ or ‘no’.”)
            Tts_engine.runAndWait()
        Break

Main loop

While True: Ask_for_id() Ask_preference()

# Ask if the learner understood and respond accordingly
Ask_understanding()

User_input = input(“Do you want to continue (yes/no): “)

If user_input and “no” in user_input.lower():
    Break