The Trade

Completely broke...Health was bad A man lost...all he had There was no hope. At least it seemed. Until one day. He had a dream. When he woke up. The dream was real. A man approached him. He made a…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Python fundamental

Python is a programming language that is interpreted when the code is run, its a great programming language to learn and easy to pick up.

Note: Theirs also a type of snake called python as well

variables are a way to store data and link it to a descriptive name that then we can call on later to display the data.

Once we create our variables we can now store all types of data to it, In python the main types of data are as following:

a. String

b. Integer

c. Float

d. Boolean

A string is a list of characters in the order you type, A character can be anything that you can type on the keyboard like letters, numbers and special characters (£$%^&*).

Python recognises strings as characters that are surrounded by quotation marks (“” or ‘’).

Integers are basically whole numbers that have no decimal, for example 1 ,45 and 232323.

Float are very similar to integers in that they are numbers, the difference between them is that Floats are numbers with decimals and integers are whole number with no decimal space. For example 1.0, 2.0 and 15.5 are all floats.

Boolean have values of True or False in programming the are usually to provide logic to your code, for example you may want a piece of code to run if something is true or maybe another piece of code to run if something is false.

In programming loops are really great tools to use on your code, one of the main advantages of using loops is that you don’t have to keep repeating your self again and again. However they are sometimes dangers in using loops, you can in some occasions create an infinite loops if you don’t set the loop up correctly.

We are going to cover only two types of loops:

For

While

You can loop through up to a set value that you have selected by using the:

for example if you did:

while loops are similar to for loops but the main difference is that while loops keep on looping until the condition you set them is no longer accepted. However with while loops you have to be careful to not make an infinite loop.

Function are amazing feature that allows us to divide our code into useful blocks, the advantages of using functions makes our code more readable as well as makes the code reusable.

Defining Functions

To define your function you first need to use the keyword def followed by the name you want to give the function and parentheses ().

Note: at then end of the function when you include () you also need to add : and indent your code within the function.

example

A function called welcome is created that has print (“hello”) in it, when we call the function the code in it get executed and hello is printed to the console.

Hope you enjoyed this :)

Add a comment

Related posts:

Speed Up Your Workflow With IntelliJ

I do the bulk of my test automation development in Kotlin/Java or Python languages. After the programming language, a very important component for the dev workflow is a good IDE. Purists generally…

What is your policy?

This morning I was at an office to pay some bills, when I saw a big poster that said Honesty is the best policy. This is ascribed to many people, but it seems the wide consensus is that it came from…

Bot Love

CyberCore terminated the program. “Scared shitless” was how Karen summed up the executive meeting when she briefed her team. Arms crossed and locked together tighter than her jaw, navy blouse, navy…