0% found this document useful (0 votes)
12 views6 pages

computing

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views6 pages

computing

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

1.

Techniques in Computational Thinking


Computational thinking is a problem-solving approach inspired by computer science. The
main techniques are:

1. Decomposition: Breaking down a complex problem into smaller, manageable parts.


○ Example: Sending an email involves breaking it into steps like writing,
entering the recipient’s address, adding attachments, and sending.
2. Abstraction: Focusing on the essential details of a problem while ignoring
unnecessary ones.
○ Example: When sending an email, you focus on the user steps, not the
underlying server processes.
3. Pattern Recognition: Identifying similarities or trends to simplify the problem.
○ Example: Sending an email follows a pattern similar to sending a text
message.
4. Algorithmic Thinking: Creating step-by-step instructions to solve a problem.
○ Example: Designing a set of steps to write, check, and send an email.

2. Techniques in Programming
Programming techniques help write effective and efficient code. Here are the key
techniques:

1. Conditional Statements (if-else): Making decisions based on certain conditions.


○ Example: If the email address is valid, then send the email; else display an
error message.
2. Loops (for, while): Repeating instructions multiple times.
○ Example: Checking and verifying all email addresses in a recipient list using a
for loop.
3. Functions: Dividing the code into reusable blocks.
○ Example: Creating a function send_email() that handles all tasks related to
sending an email.
4. Debugging: Finding and fixing errors in the code.
○ Example: Using a debugger to locate where a program fails during email
validation.
5. Optimization: Improving code to make it faster or consume fewer resources.
○ Example: Reducing redundant steps when processing email attachments.

3. Errors in Programming
Errors in programming can be categorized into the following types:

1. Syntax Errors: Mistakes in the code structure or language syntax.


○ Example: Forgetting a colon in Python: if email == valid_email
print("Success").
2. Logical Errors: The program runs but produces incorrect results due to flawed logic.
○Example: Sending an email to the wrong recipient because of incorrect input
handling.
3. Runtime Errors: Errors that occur during program execution.
○ Example: Dividing a number by zero or accessing a file that doesn’t exist.
4. Type Errors: Operations between incompatible data types.
○ Example: Adding a string to a number: 5 + "email".
5. Input/Output Errors (I/O Errors): Errors when dealing with external inputs like files.
○ Example: Trying to attach a file that does not exist on the computer.

4. Algorithm and Flowchart for Sending an Email


Algorithm
Here is a step-by-step algorithm for sending an email:

1. Start
2. Prompt the user to enter the recipient’s email address.
3. Verify if the email address is valid.
○ If invalid, display "Invalid Email Address" and stop.
4. Prompt the user to enter the subject of the email.
5. Prompt the user to write the content of the email.
6. Ask if the user wants to attach a file.
○ If yes, prompt for file selection and attach it.
7. Confirm with the user before sending.
8. Send the email.
9. Display "Email sent successfully."
10. End

Flowchart
Here is a flowchart to represent the algorithm visually:

yaml
Copy code
+---------------------+
| Start |
+---------------------+
|
v
+---------------------+
| Enter recipient's |
| email address |
+---------------------+
|
v
+---------------------+
| Validate email? |
+---------------------+
/ \
Yes No
| |
v v
+-------------------+ +------------------+
| Enter subject | | Display "Invalid |
| and message | | Email" |
+-------------------+ +------------------+
|
v
+------------------------+
| Attach file? |
+------------------------+
/ \
Yes No
| |
+-----------------+ |
| Attach file | |
+-----------------+ |
\ /
v
+------------------------+
| Confirm and send email |
+------------------------+
|
v
+------------------------+
| "Email sent successfully" |
+------------------------+
|
v
+-------+
| End |
+-------+

Here is a representation of flowchart symbols used in programming and algorithms:


Basic Flowchart Symbols
1. Oval: Represents the Start or End of a flowchart.

Example:
sql
Copy code
+--------+
| Start |
+--------+


2. Diamond: Represents a Decision or condition (e.g., "Is the email valid?").

Example:
lua
Copy code
+------------------+
| Is email valid? |
+------------------+
/ \
Yes No


3. Rectangle: Represents a Process or step (e.g., "Write the email content").

Example:
diff
Copy code
+------------------+
| Write content |
+------------------+


4. Arrow: Shows the flow or direction of steps in a flowchart.

Example:
sql
Copy code
+--------+ ---> +--------+
| Start | | Process|
+--------+ +--------+


5. Parallelogram: Represents an Input/Output operation (e.g., "Enter recipient's
email").

Example:
diff
Copy code
+------------------+
| Enter recipient's|
| email |
+------------------+

Flowchart Example for Sending an Email


Here’s a full flowchart using these symbols:

mathematica
Copy code
+------------------+
| Start | <-- Oval
+------------------+
|
v
+------------------+
| Enter recipient's| <-- Parallelogram (Input)
| email address |
+------------------+
|
v
+------------------+
| Is email valid? | <-- Diamond (Decision)
+------------------+
/ \
Yes No
| |
v v
+------------------+ +------------------+
| Enter subject | | Display "Invalid|
| and content | | Email Address" |
+------------------+ +------------------+
| |
| v
| +------------------+
| | End | <-- Oval
| +------------------+
|
v
+------------------+
| Attach a file? | <-- Diamond (Decision)
+------------------+
/ \
Yes No
| |
v v
+------------------+ +------------------+
| Attach the file | | Confirm email |
+------------------+ | and send |
\ / +------------------+
\ / |
\ / v
+------------------+
| Send the email |
+------------------+
|
v
+------------------+
| Email sent |
| successfully |
+------------------+
|
v
+----------------+
| End | <-- Oval

You might also like