Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,409 members, 7,819,467 topics. Date: Monday, 06 May 2024 at 04:50 PM

Python Tutorial - Programming (2) - Nairaland

Nairaland Forum / Science/Technology / Programming / Python Tutorial (9337 Views)

My First Python Tutorial Has Been Released. / Please Am Stuck Here. (python Tutorial) (2) (3) (4)

(1) (2) (3) (Reply) (Go Down)

Re: Python Tutorial by Nobody: 10:41pm On Jun 29, 2016
DJHANDSOME:
am following cool


ah really would love to learn three pro. languages before this year runs out


java smiley


python smiley


C sad

have an OCA in JAVA grin , Learnt C with Linux. It's not about number of programming languages you know though. What matters is how fluent you are with them. What matters MOST is knowing how to solve problems. Na there be the real koko. Seeing a problem, breaking it down to little parts, and building a solution from the pieces.

1 Like

Re: Python Tutorial by Nobody: 12:07am On Jun 30, 2016
.
Re: Python Tutorial by gistsky: 12:42pm On Jun 30, 2016
Weldone sir. i like ur method of teaching. ur name tho
Re: Python Tutorial by Nobody: 2:35pm On Jun 30, 2016
gistsky:
Weldone sir. i like ur method of teaching. ur name tho
Thank you. It's a cool name. Son of the morning star. Jesus was a Lucifer too.
Re: Python Tutorial by UncleSnr(m): 1:00pm On Jul 01, 2016
sonOfLucifer:
PRACTICE
Using the Python Shell, calculate the following, find the results of the following expressions.
– 8 + 5 * 4 – 3.
– 10 raised to power 8.
– The remainder when 6 is divided by 5.
Computers read instructions from left-to-right, line-by-line. The parenthesis symbol “()” when used around a part of an expression, indicates to the computer to evaluate its contents first. To understand this, run the following expressions.
– (8 + 5) * 4 – 3.
– 8 + (5 * 4 – 3).
– 8 + 5 * (4 – 3).
– 8 + (5 * 4) – 3.
You no tell us say we must put "print" before the maths.
Re: Python Tutorial by Nobody: 1:14pm On Jul 01, 2016
UncleSnr:

You no tell us say we must put "print" before the maths.
If you use Shell mode, you don't need to.

If you type it in a script, you'll need the print() to display the answer. I'll throw more light on this in a future lesson.

1 Like

Re: Python Tutorial by Hollakay1(m): 5:28am On Jul 03, 2016
sonOfLucifer:
angry grin
Will update this weekend.
Waiting for the update please.
Re: Python Tutorial by Ithee(m): 11:20pm On Jul 03, 2016
No noise pls. Oya kontunu oga mi
Re: Python Tutorial by Hollakay1(m): 11:34pm On Jul 03, 2016
Ithee:
No noise pls. Oya kontunu oga mi
Hmmm, you no count book @all.
Re: Python Tutorial by Hollakay1(m): 11:34pm On Jul 03, 2016
Ithee:
No noise pls. Oya kontunu oga mi
Hmmm, you no count book @all. SMH
Re: Python Tutorial by noordean(m): 5:15pm On Jul 04, 2016
sonOfLucifer:


have an OCA in JAVA grin , Learnt C with Linux. It's not about number of programming languages you know though. What matters is how fluent you are with them. What matters MOST is knowing how to solve problems. Na there be the real koko. Seeing a problem, breaking it down to little parts, and building a solution from the pieces.

That's one of the problems of Nigerian programmers. Jack of all trades

1 Like

Re: Python Tutorial by Edoziesmart(m): 6:38pm On Jul 04, 2016
It is so obvious that many nigeria youth mostly "teen" do aspire to become a leet programmer but ony the strong and bold people learn it to the hardest part. It is the game for the survival and fitness

Programming no be beans talk. So if you know you wont create time to learn it fully better quit now at the beginning of the road to avoid wasting your leisure time learning noting.

Anyway am a java developer but am eager and desire to port into python cause it seems java is very complicated. #Son_of_lucifer i would be happy if you add me up on facebook with this my name. Though am into beingnner aspect of python now through the help of this python king called "pythonian"
Re: Python Tutorial by Nobody: 9:49pm On Jul 04, 2016
Sorry guys. Got banned on Friday. Poor timing.
Edoziesmart macaranata buharifan@gmail.com
Re: Python Tutorial by Nobody: 11:18pm On Jul 04, 2016
noordean:


That's one of the problems of Nigerian programmers. Jack of all trades
True. Chop small here, chop small there, no digestion.

1 Like

Re: Python Tutorial by Nobody: 12:20am On Jul 05, 2016
sonOfLucifer:

Thank you. It's a cool name. Son of the morning star . Jesus was a Lucifer too.
i lost all of my friends on twitter because i typed "i am a hardcore luciferian". na wa for my naija brothers sad
Re: Python Tutorial by Nobody: 10:18am On Jul 05, 2016
LESSON 6
In the previous lesson, we learnt to work with numeric values in Python. Most times, the values we may want to represent could be a combination of alphabets, numbers and other symbols.

We may want represent data such as your e-mail address (something@google.com), your name(Kelechi) or your matriculation number (“MA01/4432”). Each alphabet, number or symbol is called a character. A string is a combination of characters.

CHARACTERS
A character is any letter, number, space, punctuation mark, or symbol that can be typed on a computer. There are a few terms you should be conversant with if you want to be a solid programmer.

Whitespace
If you hit the tab key or space bar on your keyboard, it moves the cursor a little distance forward. The Tab key and Spacebar on your keyboard produce what is called whitespace. Think of them as invisible characters. They do not show on the screen but they represent space. The spacebar moves the cursor a single space. The tab key usually moves the cursor four spaces.

Newline:
Hitting the Enter key on your keyboard moves the cursor to a new line. This is called as new line character and most programming languages represent it as “\n”. We’ll talk more on this later.

CREATING A STRING IN PYTHON
To create a string value in Python, enclose the value in double quotes (” “) or single quotes(‘ ‘).

Open IDLE in Shell mode. Type in each value and enclose in quotes. Make sure the quotes match, else you’ll get an error. That means if it begins with a double quote(“), end it with a double quote(“).



Similar to numbers, string values also have operators that can be used to combine, modify or manipulate them.


WORKING WITH STRINGS
Open Idle in Shell Mode and enter the following code.
"Hello"
"The name's Bond " + ", James Bond
"Knock" x 2
"Knock"/2

Strings in Python
Confused? Don’t be. Let’s go through each of the lines.
On the first line, we entered a name and enclosed it in double quotations to indicate it is a string value. Python recognizes text within the quotation marks as strings. If you do not enclose the text in quotation marks like we did on the second line, an error will occur.

On the third line, we did something really strange. We combined two strings into one using the mathematical operator(+). This is known as concatenation.

Understanding how this third line works is crucial to solidifying our understanding of datatypes. The datatype of a value determines what operators can be applied to it, and the manner in which these operators are applied.

Numeric datatypes allow us to add, subtract, multiply and divide values. If you use the addition symbol(+) on numeric values, it will treat them as numbers and add them.

With strings, the addition symbol does something different. It combines both strings and returns a new string value. So “Choco” + “milo” will return "Chocomilo” and “2” + “3” will return “23”.

The multiplication operator(*) also acts differently when used with strings. On Line 4 of our prgram, we multiplied a string by two. The multiplication operator(*), when applied to strings, repeats the string. For example, “Nawa” * 3 will return “NawaNawaNawa” as result.

CLOSING
Understanding operators and how to use them is vital. A list of operators in Python can be found at this link. As we progress, we will learn about other operators that can be used to make comparisons between two values and other interesting functions.

So far, we haven’t been able to do much with these values. In the next lesson, we will learn how to store values so we can reuse them or make changes to them. Variables… coming up next…
Re: Python Tutorial by gistsky: 1:02pm On Jul 05, 2016
We are moving forward.
Thanks for d update.

1 Like 1 Share

Re: Python Tutorial by Hollakay1(m): 3:04pm On Jul 06, 2016
Am enjoying this... Waiting for the next update
Re: Python Tutorial by Nobody: 1:04am On Jul 08, 2016
Pardon me. This lesson might be a bit rushed.My weekend schedule looks tight, but I wouldn't want to delay the thread. Na sleep eye I use type this lesson. Please, if you notice any mistakes, or if the explanations need to be improved, do let me know.

2 Likes 1 Share

Re: Python Tutorial by Nobody: 1:08am On Jul 08, 2016
LESSON 7
So far, so good. We've learnt how to create and use numeric and string values. In this lesson, we'll talk about variables and how to use them.

WHAT ARE VARIABLESS

Open IDLE in Shell Mode. Enter the following lines of code, and hit Enter.
Notice what happens everytime you enter. Shell Mode evaluates the instruction you've entered and immediately displays or prints the result to your screen.
Hitting Enter after typing an instruction in Shell Mode tells the computer to execute the given instruction.
Let's assume we would like to store or 'hold' the result of an expression(or a value) so we can manipulate it later. In simple English, we want our program to 'remember' a value, to 'hold on' to a particular value. This is where variables come in.

A variable is a name that refers to a value. All we are saying is 'oh boy, hold this value for me, if i call you, give me the value'. To create a variable, you type a name and put the '=' symbol after it.

If you're a Mathematician, you might have read the symbol as 'equal to'. As a programmer, that is wrong. The '=' symbol is an assignment operator. It assigns the value of whatever expression is on the right hand side to the variable on its left.



Be careful when picking a name for your variable. Make sure the name describes the value/data it refers to. There are three general rules you should remember when creating variables.

Variables names must start with a letter or an underscore, such as: _underscore. underscore_
The remainder of your variable name may consist of letters, numbers and underscores. olodo2, wannabec0der. …
Names are case sensitive. case_sensitive, CASE_SENSITIVE, and Case_Sensitive are each a different variable.
Alright, let’s try some code so we get a hang of this. In Shell Mode, type the following

1 + 2


Both numbers are added and the result 3 is displayed on screen


sum = 1 + 2

Both values are added to produce a new value 3. This new value is then assigned to a variable called sum. Note that no result is printed. Type
sum at the prompt to see the value of sum

sum

Variables can also be used in expressions. You must assign a value to a variable before using it in an expression. An error will occur if you attempt to use a variable before it has been assigned a value.

sum * 3

sum = sum + 4

Weird? Not really. You should read assignment statements from the right. On the right side, the value of sum is added to 4 and the new value is then reassigned to sum. This is important.

A variable can only refer to a single value at a time. If you reassign a value to a variable, the variable will refer to the new variable it’s been assigned to. Type sum at the prompt to get its new value.


sum

Notice in the screenshot what happened when I put a space between the “+” and “=” operator. It throws a syntax error. There should be no space between += or *= and so forth.

Now try these. See if you can figure out how they work. Type sum after running each statement

sum += 2

sum *= 3

sum /= 4

These operators are also assignment operators. They’re shorthand methods of updating variables. The first one is similar to “sum = sum + 2”. It updates sum by adding 2 to i. The second one line updates

Variables can also hold string values. Try the following code in your shell prompt.


"James" + "Bond"

firstname = "James"

lastname = "Bond"

firstname + lastname

firstname + " " + lastname

fullname = firstname + " " + lastname

fullname += " Samson"

Cool. Now, you should have a proper understanding of what variables are and how they are used. Slowly, we are learning the building blocks of Python programs, and with time, we will combine this knowledge to write meaningful and useful programs. In the next lesson, we will talk about functions.
Re: Python Tutorial by gistsky: 6:37pm On Jul 08, 2016
Ok sir. We are following.
Thanks.
Re: Python Tutorial by omokoladele(m): 2:56pm On Jul 09, 2016
following boss.

I love python!
Re: Python Tutorial by holuphisayor(m): 8:26am On Jul 10, 2016
Python is quite easy to learn if you take your time to learn vb.net for example. Then you can build on that.

Download ...learnpythonthehardway.pdf
notepad++
emmets plugin for notepad++
and use windows powershell on ur pc....

Hope it helps.

1 Like

Re: Python Tutorial by calculator123(m): 12:27pm On Jul 12, 2016
son of lucifer i be ur secret follower oh.been using python since april due to a course i did in my sch.....i discovered it has more diverse applications than the normal mathematical abilities.pls put me in the know.
Re: Python Tutorial by Nobody: 12:36pm On Jul 12, 2016
calculator123:
son of lucifer i be ur secret follower oh.been using python since april due to a course i did in my sch.....i discovered it has more diverse applications than the normal mathematical abilities.pls put me in the know.
Hey, heeehe thanks.

Yeah, Python is easy to use. You can use it for data analytics and to create simple desktop apps too.

This tutorial I'm running will take you through the basics. Hopefully, we'll create a calculator app at the end of the course.

1 Like

Re: Python Tutorial by calculator123(m): 1:21pm On Jul 12, 2016
sonOfLucifer:

Hey, heeehe thanks.

Yeah, Python is easy to use. You can use it for data analytics and to create simple desktop apps too.

This tutorial I'm running will take you through the basics. Hopefully, we'll create a calculator app at the end of the course.
i actually did something similar using the scriptmode but dont know how i would convert it to an app?.i would be patient though.do u mind if i pm u
Re: Python Tutorial by Nobody: 1:51pm On Jul 12, 2016
calculator123:
i actually did something similar using the scriptmode but dont know how i would convert it to an app?.i would be patient though.do u mind if i pm u
Buharifan@gmail.com

caye
Re: Python Tutorial by deedat205(m): 9:34pm On Jul 12, 2016
Hi, developers in the house. Is there a way I can extract my file Explorer from my phone to an external storage so that it can be copied to another mobile phone?
Re: Python Tutorial by Nobody: 7:58am On Jul 13, 2016
Well done sir!
Re: Python Tutorial by TrueHeart365(m): 10:54pm On Jul 13, 2016
bro @sonofekwensugrin. i must say you are doing a very wonderful job. and i like how young Nigerians are sharing knowledge to help ech other.

i'm new to programming and i've been learning python. before i started, one pro like that told me that python is useless in Nigeria that i should learn c#, saying it's more useful.

the thing is that c# is too complex for a newbie like me with no programming knowledge.
so thank my stars that i did some reserch on my own and decided to stick to python.

my question is how far will i go with python(i intend to go in so deep that i may not have time to learn other languages like java c# etc..)? although i want to learn php, css and mysql for web developmet.

am i on the right path?

1 Like

Re: Python Tutorial by Nobody: 11:59pm On Jul 13, 2016
TrueHeart365:
bro @sonofekwensugrin. i must say you are doing a very wonderful job. and i like how young Nigerians are sharing knowledge to help ech other.

i'm new to programming and i've been learning python. before i started, one pro like that told me that python is useless in Nigeria that i should learn c#, saying it's more useful.

the thing is that c# is too complex for a newbie like me with no programming knowledge.
so thank my stars that i did some reserch on my own and decided to stick to python.

my question is how far will i go with python(i intend to go in so deep that i may not have time to learn other languages like java c# etc..)? although i want to learn php, css and mysql for web developmet.

am i on the right path?
God bless your TrueHeart grin
Python is a solid programming language for beginners and learners. I'd say only you can limit yourself. Python is becoming popular in data science, and also ethical hacking.
If you're interested in web development, Django is a Python framework used in web development. Think of frameworks as a language built on the language to make it easier. Na so I sabi explain am o.

I'd say start with Python. HTML and CSS aren't difficult to learn. I personally don't consider them programming languages.

What's your main interest?
Re: Python Tutorial by TrueHeart365(m): 8:45am On Jul 14, 2016
sonOfLucifer:

God bless your TrueHeart grin
Python is a solid programming language for beginners and learners. I'd say only you can limit yourself. Python is becoming popular in data science, and also ethical hacking.
If you're interested in web development, Django is a Python framework used in web development. Think of frameworks as a language built on the language to make it easier. Na so I sabi explain am o.

I'd say start with Python. HTML and CSS aren't difficult to learn. I personally don't consider them programming languages.

What's your main interest?

thanks for your response.

my main interest are in web development, software and app development.

so you're saying if i learn django there's no need for php and css?

aside from python being good for beginners. would you recommend it for anyone who wants to go pro in programming?

(1) (2) (3) (Reply)

Take Your Web Development Skill/Career To The Next Level By Creating A Web App / How To Generate Unique 10/11 Digits Nuban / BVN With PHP / I Have A Problem With Raise Event In C#

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 56
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.