In: Computer Science
a summary explaining the basic understanding of the
following programming concepts using a language of python:
•Variables
•Arithmetic and Logical operations
•Sequential coding (Structured programming
•Decision structure (If statements)
•Repetition structure
•Functions
with some coding demos inside visual studio code python IDE which
can be sent as screenshot. preferably a typed summary please which
can be written into powerpoint pleaseeeee ???
Variables are used as containers for storing data values.
Unlike other programming languages, Python has no specific command for declaring a variable.
In Python A variable is created the moment you first assign a value to it.
Example:----- x = 5
y = "John"
print(x)
print(y)
Variables do not need to be declared with any particular type, and can even change type after they have been set.
x = 4 # x is of type int
x = "Sally" # x is now of type str
print(x)
Arithmetic and Logical operations:----
Arithmetic operators are used with numeric values to perform common mathematical operations
Operator Name Example
+ Addition a+b
- Subtraction a-b
* Multiplication a*b
/ Division a/b
% Modulus a%b
Sequential coding (Structured programming):------
Structured programming is a program written with only the three constructions sequence, decision (if..elif statements), and repetition (while or for statements).
Important: the body of a Python if, elif, while, or for statement is indicated by indenting four spaces. Python does not use end statements.
Example:
x = 56 y = 11 z = x + y print(z)
Decision structure (If statements):-------
if statement is the most simple decision making statement. It is used to decide whether a certain statement or block of statements will be executed or not i.e if a certain condition is true then a block of statement is executed otherwise not.
Here, condition after evaluation will be either true or false. if statement accepts boolean values – if the value is true then it will execute the block of statements below it otherwise not. We can use condition with bracket ‘(‘ ‘)’ also.
As we know, python uses indentation to identify a block. So the block under an if statement will be identified as shown in the below example:
i
=
20
;
if
(i <
15
):
print
(
"i is smaller than
15"
)
print
(
"i'm in if
Block"
)
else
:
print
(
"i is greater than
15"
)
print
(
"i'm in else
Block"
)
print
(
"i'm not in if and not in else
Block"
)
Repetition structure:------
While condition: statement(s) # notice the indent from of this line relative to the while
Functions:------
A function is a block of code which only runs when it is called.
You can pass data, known as parameters, into a function.
A function can return data as a result.
In Python a function is defined using the def keyword:
def my_function():
print("Hello from a function")
-------I Hope This Will Help You------
--------Plese Give Me Positive Rating------Thank You----------