Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,154,739 members, 7,824,128 topics. Date: Friday, 10 May 2024 at 11:49 PM

Let's Learn Python-striktly Noobed!! - Programming (2) - Nairaland

Nairaland Forum / Science/Technology / Programming / Let's Learn Python-striktly Noobed!! (3496 Views)

Help! I Want To Learn Python Programming / Help! I Want To Learn Python / LET'S LEARN HOW TO CONTROL HOME APPLIANCES WITH SOFTWARE AND VOICE CONTROL! (2) (3) (4)

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

Re: Let's Learn Python-striktly Noobed!! by DharkPoet(m): 10:21pm On Aug 24, 2014
umaryusuf:

Is like you left out an important step here (of adding python PATH to system's environment variables), especially that u are using powershell to run py. It may not work on many Windows PC, which could frustrate extreme noobs...

Thanks bro for spotting this, already modified it above to address the issue.
Re: Let's Learn Python-striktly Noobed!! by Nobody: 10:23pm On Aug 24, 2014
For Users tryna set Environment variables inorder to use powershell, Do the following:

Go to Control Panel –> System Properties –> Environment Variables and select the PATH variable -> Click Edit -> Add the following line at the end of the line C:\Python27;C:\Python27\Scripts
This will create a folder called scripts where your python files will live in..

Or Run the Following command inside Powershell:

[Environment]::SetEnvironmentVariable("Path", "$env:Path;C:\Python27\;C:\Python27\Scripts\", "User"wink


Either of the two will work but its more easier using the 1st method..
Re: Let's Learn Python-striktly Noobed!! by DharkPoet(m): 6:28am On Aug 25, 2014
Djangocode: For Users tryna set Environment variables inorder to use powershell, Do the following:

Go to Control Panel –> System Properties –> Environment Variables and select the PATH variable -> Click Edit -> Add the following line at the end of the line C:\Python27;C:\Python27\Scripts
This will create a folder called scripts where your python files will live in..

Or Run the Following command inside Powershell:

[Environment]::SetEnvironmentVariable("Path", "$env:Path;C:\Python27\;C:\Python27\Scripts\", "User"wink


Either of the two will work but its more easier using the 1st method..

Thanks for the support bro
Re: Let's Learn Python-striktly Noobed!! by Nobody: 6:31am On Aug 25, 2014
Keep it up guys, i dey follow in 3D.
Re: Let's Learn Python-striktly Noobed!! by DharkPoet(m): 9:02pm On Aug 26, 2014
Been having Power problems, coupled with a blown charger. I'd try posting something tomorrow.
Re: Let's Learn Python-striktly Noobed!! by Nobody: 10:35pm On Aug 26, 2014
Sorry bro, it happens, I am sure you leave your system plugged to power like 24-7. Well I do that to, and I have learnt my lesson - to always have an extra charger in case your charger blows on a saturday night and you are stranded till monday morning - a nightmare for a programmer.
Re: Let's Learn Python-striktly Noobed!! by Capnd143(m): 4:33pm On Aug 27, 2014
Ok am in. But the problem is i will be using my phone.
I have a PC bt only have Java,C++ AND Vb6 installed, i cant Download Python because of the hilariously slow Network in my State, and i cant buy it from a vendor either because it is not available! I am really interested in this. Help me out.
Re: Let's Learn Python-striktly Noobed!! by dtermined(m): 6:44pm On Aug 27, 2014
i will also contribute to this,move on my broda
Re: Let's Learn Python-striktly Noobed!! by DharkPoet(m): 10:52pm On Aug 27, 2014
Capnd143: Ok am in. But the problem is i will be using my phone.
I have a PC bt only have Java,C++ AND Vb6 installed, i cant Download Python because of the hilariously slow Network in my State, and i cant buy it from a vendor either because it is not available! I am really interested in this. Help me out.
It aint that much bro!!
Re: Let's Learn Python-striktly Noobed!! by vinoz: 2:06am On Aug 28, 2014
I am in, quess an right in time to learn python. Thanks folks for this opportunity
Re: Let's Learn Python-striktly Noobed!! by DharkPoet(m): 9:10am On Aug 28, 2014
vinoz: I am in, quess an right in time to learn python. Thanks folks for this opportunity
Yes Bro, perfect timing!!
Re: Let's Learn Python-striktly Noobed!! by Capnd143(m): 12:36pm On Aug 28, 2014
DharkPoet:
It aint that much bro!!
by much you mean? Size? Price?
Re: Let's Learn Python-striktly Noobed!! by Nobody: 12:46pm On Aug 28, 2014
Capnd143: by much you mean? Size? Price?
He's trying to say that the downloadable file is not much, I used just around 15MB to download the file.
Re: Let's Learn Python-striktly Noobed!! by DharkPoet(m): 10:41am On Aug 30, 2014
Sorry for the delay guys. Our Next topic is Comments.

Comments are very important in your programs. They are used to tell you what something does in English, and they are used to disable parts of your program if you need to remove them temporarily. Here's how you use comments in Python as shown below.

Just include a pound/hash sign before starting a line, to begin a comment. Code commenting is a really good practice, as it helps you the programmer and other programmers understand what you're doing
Re: Let's Learn Python-striktly Noobed!! by DharkPoet(m): 10:43am On Aug 30, 2014
Next Chapter-Comments and Pound Characters

# A comment, this is so you can read your program later.
# Anything after the # is ignored by python.

print "I could have code like this." # and the comment after is ignored

# You can also use a comment to "disable" or comment out a piece of code:
# print "This won't run."

print "This will run."
Re: Let's Learn Python-striktly Noobed!! by Nmeri17: 5:53pm On Sep 01, 2014
DharkPoet: So down to installation:

Visit https://www.python.org/download/releases/2.7.8/

I saw four different files in different formats...msi. zip etc abeg which one is it?? abi am I to download all?? I'm a windows user but I want to download it with my phone
Re: Let's Learn Python-striktly Noobed!! by DharkPoet(m): 10:05pm On Sep 01, 2014
Nmeri17:

I saw four different files in different formats...msi. zip etc abeg which one is it?? abi am I to download all?? I'm a windows user but I want to download it with my phone
Get the MSI package
Re: Let's Learn Python-striktly Noobed!! by DharkPoet(m): 7:42pm On Sep 05, 2014
Sorry for the delay/break, School has really not been helping out.... been really hectic!!
Re: Let's Learn Python-striktly Noobed!! by DharkPoet(m): 7:47pm On Sep 05, 2014
Next topic we'd be treating is Numbers and Math

In this topic, we'd see how to use Python to handle basic Math calculations.
Math symbols are generally the same in Python, save for the Multiplication, Division and Modulo Operators, and we'd see difference shortly

+ plus
- minus
/ slash(Division)
* asterisk(Multiplication)
% percent(Modulo)
< less-than
> greater-than
<= less-than-equal
>= greater-than-equal

So let's do some Math Calcs
Re: Let's Learn Python-striktly Noobed!! by DharkPoet(m): 7:48pm On Sep 05, 2014
print "I will now count my chickens:"

print "Hens", 25 + 30 / 6
print "Roosters", 100 - 25 * 3 % 4

print "Now I will count the eggs:"

print 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6

print "Is it true that 3 + 2 < 5 - 7?"

print 3 + 2 < 5 - 7

print "What is 3 + 2?", 3 + 2
print "What is 5 - 7?", 5 - 7

print "Oh, that's why it's False."

print "How about some more."

print "Is it greater?", 5 > -2
print "Is it greater or equal?", 5 >= -2
print "Is it less or equal?", 5 <= -2


OUTPUT BELOW

I will now count my chickens:
Hens 30
Roosters 97
Now I will count the eggs:
7
Is it true that 3 + 2 < 5 - 7?
False
What is 3 + 2? 5
What is 5 - 7? -2
Oh, that's why it's False.
How about some more.
Is it greater? True
Is it greater or equal? True
Is it less or equal? False
Re: Let's Learn Python-striktly Noobed!! by DharkPoet(m): 7:53pm On Sep 05, 2014
Q:So what really does the Modulus operator do?
A:It returns the remainder of a mathematical division operation eg
3 % 2 = 1
7 % 5 = 2
8 % 3 = 2
Re: Let's Learn Python-striktly Noobed!! by DharkPoet(m): 7:57pm On Sep 05, 2014
Next Topic We'd be treating is Variables and Names
So what tha heck is a Variable? What's all these fuss about it?

Well think of a variable as a container that holds a specific value? This value could either be a number, letter of the alphabet, a String of text, a Boolean value etc.

In other words, a Variable acts as a box for holding these values.

Well taking an example would really help us understand this concept.
Re: Let's Learn Python-striktly Noobed!! by DharkPoet(m): 7:58pm On Sep 05, 2014
cars = 100
space_in_a_car = 4.0
drivers = 30
passengers = 90
cars_not_driven = cars - drivers
cars_driven = drivers
carpool_capacity = cars_driven * space_in_a_car
average_passengers_per_car = passengers / cars_driven


print "There are", cars, "cars available."
print "There are only", drivers, "drivers available."
print "There will be", cars_not_driven, "empty cars today."
print "We can transport", carpool_capacity, "people today."
print "We have", passengers, "to carpool today."
print "We need to put about", average_passengers_per_car, "in each car."


Output

There are 100 cars available.
There are only 30 drivers available.
There will be 70 empty cars today.
We can transport 120.0 people today.
We have 90 to carpool today.
We need to put about 3 in each car.
Re: Let's Learn Python-striktly Noobed!! by aramics: 8:24pm On Sep 05, 2014
Nice one ....easy than java(java is giving me headache)
Re: Let's Learn Python-striktly Noobed!! by dtermined(m): 9:43pm On Sep 05, 2014
Nice one bro,wetin b ur whatsapp no
Re: Let's Learn Python-striktly Noobed!! by Luka316(m): 9:37pm On Sep 06, 2014
Just got admited into this class, i hail u guys my lecturers and fellow windows,(oh! Sorry fellow students grin)

Iam commited to following this treat till the end

Guys(our teachers) thumps up
Re: Let's Learn Python-striktly Noobed!! by DharkPoet(m): 9:09am On Sep 07, 2014
dtermined: Nice one bro,wetin b ur whatsapp no
Not on Whatsapp for now.
Re: Let's Learn Python-striktly Noobed!! by DharkPoet(m): 9:11am On Sep 07, 2014
Luka316: Just got admited into this class, i hail u guys my lecturers and fellow windows,(oh! Sorry fellow students grin)

Iam commited to following this treat till the end

Guys(our teachers) thumps up
You welcome, I'll be posting a couple of topics this evening, so stay tuned all.

1 Like

Re: Let's Learn Python-striktly Noobed!! by pricelessmr: 6:41pm On Sep 09, 2014
Nice tutorial. Keep on.
Re: Let's Learn Python-striktly Noobed!! by justi4jesu(f): 8:25pm On Sep 10, 2014
Nice one...Am present smiley
Re: Let's Learn Python-striktly Noobed!! by Raypawer(m): 8:54pm On Sep 13, 2014
DharkPoet: Python could be used for developing Desktop apps, to server side programming, game dev, general purpose scripting, mobile development. etc
did u say desktop apps? what kind of desktop app? cos i know python to be for web app nd mobile app
Re: Let's Learn Python-striktly Noobed!! by umaryusuf(m): 11:39am On Sep 14, 2014
Raypawer:
did u say desktop apps? what kind of desktop app? cos i know python to be for web app nd mobile app

4sure, many kinds of desktop apps! See little Example: https://www.nairaland.com/1790669/visitors-customers-data-app-python

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

Learnt Web Development, What Next? (web-dev challenge) / Online Banking Php Script / Garage48 Winner's Idea - "A call Center Application"?

(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. 33
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.