Basic Coding

by MacHel0602a in Circuits > Computers

2888 Views, 24 Favorites, 0 Comments

Basic Coding

Screen Shot 2016-05-02 at 8.21.01 AM.png
Screen Shot 2016-05-02 at 8.21.09 AM.png

This instructable goes over a few basic codes that are often used in coding

Variables

File_000.jpeg
File_001.jpeg

A variable is a reference to certain information. You would set these variables like this:

x = apples

Variables is where information can be maintained and referenced.

In this image I made three variables, which were:

Helena = "I like Kpop."

favNum = 8

changeInCar = 6.00

REMEMBER: Use spaces when coding, but not when you are naming something.

Print

File_002.jpeg
File_003.jpeg

In coding "print" doesn't mean send information to a printer, but it means show the information.

If you wanted to print out your variables information all you have to do is type "print" (No caps) and then put down the name of the variable beside it.

it should look like this:

print Helena

print favNum

print changeInCar

Type of Variables

File_004.jpeg
File_005.jpeg

If you wanted to know the type of variables you are using use "type". In order to see what type of variables you are using, use "print" and place the name of your variable in parentheses.

Once you finish the code and try it out on Python it will tell you:

<type 'str'>

<type 'int'>

<type 'float'>

These are the three types of variables that python uses.

String - a sentence or a sequence of characters.

Integer - A whole number.

Float - A decimal.

Input and Raw_input

File_006.jpeg
File_007.jpeg

Input and raw_input are similar, but work differently.

Raw_input will always make a string, but input will allow the user to give input, hence the name.