Python Programming
Python Programming
https://www.programiz.com/python-programming
https://www.freecodecamp.org/
https://youtu.be/3j_CcqRljsg?t=62
https://www.sitepoint.com/how-to-write-good-code/?
utm_source=newsletter&utm_medium=email&utm_campaign=whats_the_best_programming_language_to_learn_first&ut
m_term=2022-05-14
https://docs.python.org/3/tutorial/
Python keywords are special reserved words that have specific meanings and purposes and can't be used for
anything but those specific purposes. These keywords are always available—you'll never have to import them into
your code. Python keywords are different from Python's built-in functions and types.
A code block (body of a function, loop, etc.) starts with indentation and ends with the first unindented line. The
amount of indentation is up to you, but it must be consistent throughout that block.
Here are the naming conventions you’ll see most often in development:
Camel case: Camelcase is a naming convention for writing file or object names using compounded or joined words
with at least of those words beginning in a capital letter. Camelcase is used in programming language to name
different files and functions without violating the naming laws of the underlying language.Variable names are
written in a series of words that are joined together, with each word except the first beginning with a capital letter.
Example: firstName, lastName, printFullName(). CamelCase is used in most modern programming languages,
including several popular languages such as C, C++, Visual Basic (VB), and JavaScript to name just a few. Java
uses CamelCase as a practice for writing names of methods, variables, classes, packages, and constants. The
camelCase naming convention makes compound names more readable. For example, myOneMethod is easier to
read than myonemethod.
Pascal case: Pascal case is similar to camel case, but the first word is also capitalized. Example: FirstName,
LastName, PrintFullName().
Snake case: Snake case (stylized as snake_case) refers to the style of writing in which each space is replaced by an
underscore (_) character, and the first letter of each word written in lowercase. It is a commonly used naming
convention in computing, for example for variable and subroutine names, and for filenames. Snake case uses all
lowercase letters and underscores to separate words. Example: first_name, last_name, print_full_name(). Python
uses snake_case.
Kebab case: Kebab case is similar to snake case but with hyphens instead of underscores. Example: first-name,
last-name, print-full-name().
People skills and building trust within the team is very important.
When Python interpreter runs solely without any user-defined modules, methods,
classes, etc. Some functions like print(), id() are always present, these are built-in
namespaces. When a user creates a module, a global namespace gets created, later the
creation of local functions creates the local namespace. The built-in
namespace encompasses the global namespace and the global namespace encompasses
the local namespace.
Global namespaces are defined at the program or module level. It contains the names
of objects defined in a module or the main program. A global namespace is created
when the program starts and exists until the program is terminated by the python interpreter.
A variable created inside a function belongs to the local scope of that function, and can only be used inside that
function.
As explained in the example above, the variable x is not available outside the function, but it is available for any
function inside the function:
A variable created in the main body of the Python code is a global variable and belongs to the global scope.
Global variables are available from within any scope, global and local.
If you operate with the same variable name inside and outside of a function, Python will treat them as two separate
variables, one available in the global scope (outside the function) and one available in the local scope (inside the
function):
If you need to create a global variable, but are stuck in the local scope, you can use the global keyword.
The global keyword makes the variable global.
Python ‘for’loop.
‘for’ loop and ‘range’ function
Note: In python, the function definition should always be present before the function call. Otherwise, we will get an
error.
Python function to add two numbers
Given marks of various subjects, to find the average score and also the Grade
Printing odd numbers in a range function using ‘step’