Python For N00bz ;) - Techist - Tech Forum

Go Back   Techist - Tech Forum > Techist Forum Information > Projects and Tutorials
Click Here to Login
Reply
 
Thread Tools Display Modes
 
Old 04-20-2016, 11:41 AM   #1 (permalink)
🅱🅱🅱🅱🅱🅱🅱
 
zaka100's Avatar
 
Join Date: Nov 2013
Location: Birmingham, UK
Posts: 727
Default Python For N00bz ;)

Learning Python For Beginners Lesson 1
(learn to program the hard way the easy way)

Hi, guys. Welcome to my tutorial on Learning Python For Beginners! In the tutorial, I will attempt to teach any non-programmers the basics of python and programming. Just to make this clear, I will be teaching python 3.x.x, not 2.x.x.

Preface:
Zzzzzz..... I'm not going to write a boring, long preface. For me, it just puts me off the whole book/tutorial.

Requirements:
- A computer
- A brain
- Common sense
- A pair of hands
- Python 3 installed on your computer
- Basic knowledge on computers and how they work (if you don't know what deleting System32 does, this tutorial is not for you)
- A Basic understanding on algorithms (I will explain further on how to get a better understanding on algorithms)

Understanding Algorithms:
If you don't know what an algorithm is or how they work, it is basically step-by-step instructions to do something (e.g: an algorithm to speak is: open your mouth, make a noise through your mouth). If you still don't understand or want to learn more, try using programs like 'Scratch' and 'Stencyl' which utilise basic box dragging and dropping mechanisms to make simple algorithms and behaviours in 2D games. Eh.

Installing python:

Windows:
Go to python.org and download any version of python 3.x.x, try downloading the latest version but any version will do. Don't download any ide, it is harder to learn using those. Just use the default python IDLE.

Ubuntu (idk about other distros):
Ubuntu has python 3 already installed.
To install the IDLE, go to the Ubuntu Software Center and search 'python 3 idle'. Download the latest idle version.

The Python IDLE:


This is the python IDLE shell. It will act as the console screen for running your python code. To create a new file, do CTRL-N. To open a '*.py' file, do CTRL-O.
To run an opened python file, press F5.

Hello World:

Create a new file and paste the code:

Code:
print("Hello World!")
Run the code.

That's it! That is the hello world for python! Nothing else! Just print and 'Hello World' in speech marks and brackets! The print function is used to display text on the console - not like that takes much thinking.

Looking At Variables:

Have a look at the following code:

Code:
text = "I like cake"
print(text)
What do you think it does? If you thought it would print 'I like cake', then you are right!

A variable is when you assign a name to something. It is a bit like saying 'do your chores' instead of saying 'wash the dishes, clean your bedroom, mow the lawn...'.

What the code means is that in line 1 it is saying in line 1 that "by when i say 'text', I mean 'I like cake'.

There are three types of variables I would like to talk about, strings, ints (integers) and floats.

Strings:
A string is any sequence of characters (any utf-8 character) in speech marks (double or single). E.g:
Code:
"Example String"
"Example String 2 $)!%^~"
Integers:
An integer is any whole number. It can be negative too. It doesn't have any speech marks. E.g:
Code:
138
-875
Floats:
A float is basically an integer but with a decimal point. E.g:
Code:
492.85
-42.967
The '+' sign:
For strings, the '+' sign is used to join two strings together into one.
E.g:
Code:
string1 = "Hello "
string2 = "User"
joined = string1+string2
For integers and floats, the '+' sign is used to 'add' numbers together. '-' means minus, '/' means divide, '*' means multiply, '**' means multiply to the 'power'.
E.g:
Code:
int = 2+4 # The answer is 6

int1 = 5
int2 = 9
final_int = int1*int2 # The answer is 45


float = 2.5+4.2 # The answer is 6.7

float1 = 2.5
float2 = 2.0
final_float = float1+float2 # The answer is 5.0
Converting Variables:

Here is are some situations:
Code:
Situation 1:
number = 10+2.5 # You are expecting 'number' to be 12.5

Situation 2:
text = "My Age: "+5 # You are expecting 'text' to be 'My Age: 5'

Situation 3:
math = "5"+2.1 # You are expecting 'math' to be 7
Situation 1 will work however it is better to take my advise that I will tell later.
Situation 2 and 3 will not work. It will result in a 'TypeError' because you cannot add a string and int/float together. The python interpreter does not know if you want to add the variables together or to join them.

To fix this, you will have to convert the variables. You can convert variables to a string by doing 'str("Example String")', you can convert to an int by doing 'int(100)' and you can convert to a float by doing 'float(100.0)'.
E.g:
Code:
Before:
text = "5"+2

After:
number = int("5")+2


Before:
text = "My Age: "+5

After:
text = "My Age"+str(5)
Thanks for reading. Soon I will update my tutorial and add more . Tell me what you think.
Zaka100
__________________

__________________

My Build
CPU - AMD X4 860k @ 3.7ghz
GPU - Nvidia GeForce 780
RAM - 2x HyperX Fury 4gb
MOBO - MSI A78M-E35
SSD - 120gb Kingston Hyper X
HDD - WD 320gb
Steam: zaka100123 | Snapchat: zakzaka100
zaka100 is offline   Reply With Quote
Old 04-20-2016, 07:40 PM   #2 (permalink)
Newb Techie
 
Join Date: Mar 2015
Location: America
Posts: 39
Send a message via Skype™ to littleefoxx
Default Re: Python For N00bz ;)

I'm actually interested in learning more about Python. I already know the basics but I think this definitely would've helped me if I hadn't. Looking forward to the next update.
__________________

littleefoxx is offline   Reply With Quote
Old 04-21-2016, 10:56 AM   #3 (permalink)
🅱🅱🅱🅱🅱🅱🅱
 
zaka100's Avatar
 
Join Date: Nov 2013
Location: Birmingham, UK
Posts: 727
Default Re: Python For N00bz ;)

Just updated my tutorial. Talked more about variables, etc.
__________________

My Build
CPU - AMD X4 860k @ 3.7ghz
GPU - Nvidia GeForce 780
RAM - 2x HyperX Fury 4gb
MOBO - MSI A78M-E35
SSD - 120gb Kingston Hyper X
HDD - WD 320gb
Steam: zaka100123 | Snapchat: zakzaka100
zaka100 is offline   Reply With Quote
Old 07-07-2016, 05:10 PM   #4 (permalink)
Junior Techie
 
Area-1255's Avatar
 
Join Date: Jan 2015
Location: USA
Posts: 99
Default Re: Python For N00bz ;)

You should talk about how specific functions relate to practical use in the real-world. Try to create a visual scenario, so talk about (eventually), at least in example, how a python script could go further than say, something developed using C++.

Other than that, good start OP!
Area-1255 is offline   Reply With Quote
Old 10-03-2016, 11:21 AM   #5 (permalink)
Newb Techie
 
Join Date: Mar 2016
Location: Netherlads
Posts: 17
Default Re: Python For N00bz ;)

It's very good that you want to teach people...but, maybe, firstly you should become an expert. At large, very nice way of presentation, but it looks like you don't have much experience. It's only my opinion and I don't want to harm anyone
Accid89 is offline   Reply With Quote
Old 10-03-2016, 05:13 PM   #6 (permalink)
🅱🅱🅱🅱🅱🅱🅱
 
zaka100's Avatar
 
Join Date: Nov 2013
Location: Birmingham, UK
Posts: 727
Default Re: Python For N00bz ;)

Well I wouldn't say Im a noob myself, I don't really know all those professional coding practices because I'm self taught 15 year old and I find all that stuff boring. I find coding fun and as long as this tut teaches what its supposed to teach then I'm happy.

Im not disagreeing that I lack experience, if I look at this tut a few years later I'm probably gonna cringe
__________________

My Build
CPU - AMD X4 860k @ 3.7ghz
GPU - Nvidia GeForce 780
RAM - 2x HyperX Fury 4gb
MOBO - MSI A78M-E35
SSD - 120gb Kingston Hyper X
HDD - WD 320gb
Steam: zaka100123 | Snapchat: zakzaka100
zaka100 is offline   Reply With Quote
Old 10-03-2016, 05:33 PM   #7 (permalink)
Private Joker
 
carnageX's Avatar
 
Join Date: Feb 2007
Location: South Dakota
Posts: 24,333
Default Re: Python For N00bz ;)

Quote:
Originally Posted by zaka100 View Post
Well I wouldn't say Im a noob myself, I don't really know all those professional coding practices because I'm self taught 15 year old and I find all that stuff boring. I find coding fun and as long as this tut teaches what its supposed to teach then I'm happy.

Im not disagreeing that I lack experience, if I look at this tut a few years later I'm probably gonna cringe
Be careful with that. Getting into bad habits is easy, especially when teaching yourself. This is why I advocate the vetted tutorials (from places like CodeAcademy), as they follow industry standards, and other good habits/practices.
__________________

__________________
Laptop: MSI GT70 2OC-059us | i7-4700MQ | 16GB | GTX 770m | 500GB SSD / 750GB HDD | 17.3" | Win10 Pro
Desktop: 4690k | 12GB g.Skill RipJaws | GTX 970 | 520hx | Z87X-UD4H | Corsair Vengeance C70 | Corsair H110 | Acer 25" | Acer 22" | Win10
Mobile: Samsung Galaxy Note 5


If I help you, or you just like what I said, rep me by clicking the under my post
carnageX is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Python Guide? phandentium Programming 3 11-05-2005 07:55 PM
Python burst trying to eat alligator! Law Off Topic Discussion 3 10-17-2005 12:46 AM
quick python help kyd Programming 0 08-15-2005 09:05 AM
Little help with python. JayMan Programming 2 07-05-2005 11:00 AM
What's easier to learn? Python or QBasic? CGKGS Programming 2 11-11-2004 05:24 PM


Our Communities

Our communities encompass many different hobbies and interests, but each one is built on friendly, intelligent membership.

» More about our Communities

Automotive Communities

Our Automotive communities encompass many different makes and models. From U.S. domestics to European Saloons.

» More about our Automotive Communities

Marine Communities

Our Marine websites focus on Cruising and Sailing Vessels, including forums and the largest cruising Wiki project on the web today.

» More about our Marine Communities


Copyright 2002- Social Knowledge, LLC All Rights Reserved.

All times are GMT -5. The time now is 07:43 AM.


Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2017, vBulletin Solutions, Inc.