Basic Programming
Basic Programming
Some Definitions:
*Programming techniques:
+Procedural: (private opinion): divide the problem into other small problem,
solve all the problem leading to the final result (pure logic)
1.Survey 4. Check
2.Analyse 5. Transfer
3.Design 6.maintain
Definitions
* Variables: are like boxes where you store stuff (like numbers or
words).
*Operators:
Example:
*Value: A value is just a piece of information that Python works with. It could
be a number, a word, or even something more complex. (Ex: 18; “hello”;
3,14;...)
*Data Type: A data type is the kind of value you’re dealing with. In Python,
every value has a data type. It tells Python what kind of thing it is and how to
handle it.
-Some common data types:
+String: This is for text, like "Hello!" or "Python is fun!". Strings are always
written inside quotes.
+Boolean: A Boolean is a type of data in Python that can only have one of two values:
It’s kind of like a light switch: it can either be ON (True) or OFF (False). There's no in-
between.
Booleans are super useful when we want to make decisions or check if something is right or
wrong.
For example:
Example in Context: Let’s say we’re building a simple program to decide if you’re old
enough to vote. In many countries, you need to be at least 18 years old to vote.
+It’s like a megaphone that allows your program to speak and show
information on the screen.
+You put whatever you want to display inside the parentheses ().
+You can also use print() to display the value of variables (those little boxes
that store information).
+You can combine text and variables in one print() statement. You just add
them together using the + symbol.
Ex:
+Instead of using the + symbol and converting numbers to strings, you can
use f-strings (formatted strings). They make it much easier to print
variables inside text.
Ex:
+Is a built-in function in Python that lets you ask the user to type something.
It pauses the program, waits for the user to type, and then stores whatever
they type as text.
+Think of it like asking someone a question and waiting for their answer.
Whatever they type becomes the "answer" that you can use later in your
code.
+How it works (private opinion): use input mean you design space for the
user to put their input( a problem, a math, an information,...), the
programme will understand and then stored whatever they types as text.
+Input is always text . Whatever you type using input () comes in as a string
(text), even if you type a number.
+If you need to use numbers (for calculations, etc.), you must convert the
input from a string to a number using either int() (for whole numbers) or
float() (for decimals).