DEV Community

Cover image for Introduction to Python(Beginner)
mary nyambura
mary nyambura

Posted on • Edited on

Introduction to Python(Beginner)

Hi,
This is a brief documentation of my beginner understanding of python.I am definitely looking forward to learning more and improving on my python skills.

Python is a computer programming language often used to build websites and software, automate tasks, and conduct data analysis.
What can you do with python? Let me mention a few things:

  1. Data analysis and machine learning
  2. Web development
  3. Automation or scripting
  4. Software testing and prototyping
  5. Everyday tasks

In python we have:

Variables

container for a value within your own program.
you can introduce a variable using the = sign

Strings

-sequence of texts.(str)
-symbolised by using " "
-have inbuilt methods that enable easy manipulation of strings eg. str.strip()
you can see the different methods atpython_docs

Integers

  • mathematical numbers -used with operators to perform statistical and mathematical operations you can see the different operators and their functions at W3_schools

Conditionals

  • allow your program to make decisions as per the conditions set. They include: If statements -if statement compares the variables to the condition set. If the condition of is met, the print statement is executed.

if,elif, else
First, the first if statement is evaluated if false, Then, the second if statement runs its evaluation, if false , the last if statement runs its evaluation.This flow of decisions is called “control flow.”
if statement is evaluated. If this statement is found to be true, all the elif statements not be run at all.

or
allows your program to decide between one or more alternatives.
and
allows your program to check two conditions that have been met.
match
can be used to conditionally run code that matches certain values.

Loops

are a way to do something over and over again.
They include:
while loop
loop will repeat a block of code over and over again.
this can be tedious therefore requires you to break or use iteration in order to end the loop.
for loop
iterates through a list of items to execute and produce the intended output.
list- is a list of multiple values.

Functions

-verbs or actions that the computer or computer language will already know how to perform.
-You can introduce your own functions by calling the def function.

Bugs

-mistakes, problems for you to solve
you can identify and see possible solution in your terminal window

Exceptions

things that go wrong within our coding.
try, except
is a method for testing out user input before something goes wrong, modify your code, catch the error and return the desired output.

Comments

way for programmers to track what they are doing in their program which is symbolised by starting the line with #

Pseudocode

important type of comment that becomes a special type of to-do list.

Dictionaries

shows the association between two variables that links two variables ,key&value using curly brackets i.e {"key":"value"}

Libraries

-are bits of code written by you or others can you can use in your program.
-libraries contain modules that can be implemented
into your own program using the word import that contain in built functions you could use.
random built-in module that you can use to make random numbers
statistics built-in statistics module to perform statistical operations
sys module that allows us to learn about what the user typed in at the command line
in sys slice is a command that allows us to take a list and tell the compiler where we want the compiler to consider the start of the list and the end of the list using the Len function.

APIs

“application program interfaces” allow you to connect to the code of others.

Top comments (0)