This technique is highly effective for chatbots and problem-solving tasks. It also helps reduce hallucinations by incorporating a form of quality control. The process involves: Starting with an initial prompt Getting the AI’s first response Sending a reflexion prompt asking the AI to review and reflect on its first answer Receiving an optimized response, improved […]
Python For Loop
Loops are used to repeat a block of code multiple times. “for” loop in python is used when the number of repetition is known. “while” loop is used when the number of repetition is not known in advance, or can be infinite but there have to be a condition for stopping or exiting out the […]
Python Dictionaries
A Python dictionary is a built in data type used to store key-value pairs. It is similar to a real dictionary where you have to look up a word (key) to find its defintion (value) In Python, a dictionary stores data in linked key-value pairs Each key is connected to a specific value, making it […]
Python sets
A set in Python is a built-in data type used to store unique elements—that is, it automatically removes duplicates. Sets are defined using curly braces {}, and they are unordered and unindexed, meaning the items have no specific position or order. While sets are generally unchangeable in terms of individual items (you can’t change elements […]
Python Lists
https://www.youtube.com/watch?v=nQgN1y_KGLc&list=PLcQVY5V2UY4JlNQqDqmxwXgUy6QGhpgVY&index=3#numbers, booleans, string, list of lists#matrix is a 2d list#part 1 make your first list#list with numbers#list with strings #part 2 grab elements grab multiple elements from listhttps://go.elementor.com/widget-image #every 2nd letter #unpacking #part 4 replace elements #Part 5 Methods #ascending #return index #add to python list #add another list using extend metiod #3rd way to […]
Python If Elif Else
Conditional Statements and Logical Operators in Python Use if, elif, and else to control the flow of your program based on conditions. You can write nested conditions (conditions inside other conditions) for more complex logic. Python supports comparison operators (like ==, !=, <, >, <=, >=) to compare values. You can combine conditions using logical […]
Python Variables
Variables are used to store data in a computer’s memory. A variable’s name should clearly describe the kind of data it holds. In Python, you don’t need to declare the data type of a variable—Python automatically detects it. Some common data types in Python include: Integers (int) for whole numbers Floats for decimal numbers Booleans […]
Python Convert Data Types
We are going to be looking at: type castingconverting data typestype conversionhttps://youtu.be/fEPwzKUEFtk we use the type() methd to see what type something is. Here we can see the type of “11.5” is a float. Implicit: Automatically handled by Python (no manual conversion needed) Explicit: Manually converting one data type to another Example 1 – Addition […]
Python Data Types
We are going to be looking at the datatypes in Python The data types in Python includes. int, float, none, range, complex, bool, strings, list, set, touple, dict Lets start with numbers. we have the int, float, complex and bool Example 1 Integers the type() function is used to return the type of value of […]
Python Operators
We are going to be Covering Arithmetic, Comparism, Logical and Assignment Arithmetic Operators Arithmetic Operators are used to perform mathematical operations like addition, subtraction , multipliation e.t.c Example 1 Addition Here we add a + b using th python addition operator Example 2 Subtraction Here, we subtract b from a using the python subtraction operator […]