Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

PYTHON BASIC SUMMARY

This WRITEUP is a summary/guide for new interested python learners! 

~Written and Made by Abstract

Python is an object-oriented interpreted high-level programming language. It is a general purpose and is used to develop GUI(graphical user interface) and web applications. With python, we can concentrate on the business logic of our codes rather than investing a lot of time in common programming tasks.

Python Use:

-->GUI(graphical user interface) 

-->Web Applications-Machine Learning/Data Science Module etc

 -->Many other applications as it is the most popular programming language

General Knowledge of Python:

-->Python was created by Guido van Rossum, the intitial codes was published as version 0.9 on 20      February 1991 and it grew up to Version 1 in January 1994.

-->Python was named after tv show called Monty Pythons Flying circus

1st Topic: VARIABLES & DATA TYPES

Variables and data types represent the kind of value that tells what operations can be performed on a particular data. Since everything is an object in Python programming, data types are actually classes and variables are instance (object) of these classes.

Assigning Single Values

Variables-consist of at least some sort of info inside them

Data types-tells us if the output is a string or integer or another form of data type such as the following: 

-->Floating Point(decimal) 

-->Character 

-->String 

-->Boolean 

-->Enumerated type 

-->Array

-->Date

-->integer

Boolean Value 

The boolean gives us two paths either true or false, if the password was wrong the computer will return false, however if it is right then the computer will generate true. Below is an example of a boolean:

This will return TRUE

This will return FALSE

This will show a none value

Assigning Multiple Values

This code states that all the values A, B and C will all have the value of 10, as there is an equal to    ( = ) sign in between all of them and the given value.

This code will cause all the values A, B and C to all have the values depending on the sequence they are in eg: a=10, b=15 c=20. This is because the values have comas( , ) in between them and are separated by an equal to sign( = ) causing their values to go in order to the sequence.

2nd Topic: STRINGS

Strings is one of the most essentials things to know in python. In Python, strings is an immutable sequence data type. It is the sequence of Unicode characters wrapped inside single, double, or triple quotes.

The 1st line of code runs a new line below the code

The 2nd line of code is another simple command that runs a quotation mark

This is how to print variables, you can attach them to a line of string or even integers and this method is called concatenation.

Below are the different forms of quotations, mainly used for the same purpose:

If I wanted to write a long line of code I would use a triple quotes as the next following lines will immediately and easily already be in quotes for me.

3rd Topic: THE USE OF FUNCTIONS

Function is a block of code, that can help us do various things, such as the following below: 

-->Functions can help us perform a specified operation 

-->Functions can also help us modify strings 

-->Functions can help us get information about our string 

-->ETC

Below are some of the most helpful and crucial functions:

Turns all alphabets to lowercase

Turns all alphabets to uppercase

Checks if all alphabets are uppercase, same for lowercase

We can use these functions one after another too! This comes in handy a lot

Length Function 

This counts how many character are in this string

This function, tells us which character is at the chosen position

phrase = "What is your name" 

                0123456789 

W is at position 0

Takes the first index notation

print(phrase.index("z")) 

This will give us a value error, because there is no such character in the phrase

Index Function - This function helps to locate the index notation of the character

This function helps us replace words or even characters, and it is personally one of my favourite functions

4th Topic: WORKING WITH NUMBERS

Number data types store numeric values. They are immutable data types, means that changing the value of a number data type results in a newly allocated object. Number objects are created when you assign a value to them.

BASICS

Print a whole number

Print a decimal number

Print a negative number

Operators - In python you can do all sorts of mathematical sums eg:

Order of Operations

Modulus Operator

Converting Integers into Strings

We do this with the help of the tool (str), which also means string

More Operators

abs = absolute value

This basically, just gives the power to a number (3^2)

This function gives us the larger number out of the three chosen, you can also choose more than three numbers, if you wish

This is the opposite of the (max) function, it choose the lowest number

This rounds the number either up or down

Math Operators

This helps us access more math functions

This function rounds down no matter what

This function rounds up no matter what

This function helps us find the square root of any number

These are just a few common maths functions, there are many other ones too!

5th Topic: LIST FUNCTION

A list is a data structure in Python that is a mutable, or changeable, ordered sequence of elements. Each element or value that is inside of a list is called an item. Just as strings are defined as characters between quotes, lists are defined by having values between square brackets ( [] ).

This allows the first array; eggs to be chosen

This allows the last array; choco powder to be chosen

This allows all the arrays after the array that is on index notation 1 to be chosen

This allows a range of arrays to be chosen if there are 6 arrays we just want the ones from 1 to 4 not all the ones from 0 to 6

This calls the list

This command allows both the two lists to merge with one and other

This command is used to add another array

This command is used to insert an array anywhere in the list

This command just easily removes a certain array that you choose

This command clears the whole list

This command removes the last array from the list

This checks weather the array is in or not in the list and also tells us which index notation it is in

If the array isn't in the list it will through an error

This counts how many times an array is in the list and the number in this case should be two

This arranges the list in a sort of manner that the first alphabet of each array is used and put in ascending alphabetical order. This also works for numbers and again in ascending order

This just turns the list around so the last array will be come the first and vice versa

This just simply copies the list

Bibliography:

-->https://www.sccollege.edu/Departments/upwardboundms/SiteAssets/Pages/Computer-    Science-/chapter5and6.pdf

-->https://www.javatpoint.com/java-string

-->https://www.digitalocean.com/community/tutorials/understanding-lists-in-python-

X

Continue with Google

By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.