₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,324,993 members, 8,419,845 topics. Date: Thursday, 04 June 2026 at 02:11 AM

Toggle theme

Learn Python With Me - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingLearn Python With Me (965 Views)

1 Reply (Go Down)

Learn Python With Me by quickhubservice(op):
Hello, welcome to my thread.
I will be sharing everything I have learnt so far since I resumed my programming journey to be a full stack developer. I will be trying to explain everything learnt so far in the simplest way for anyone to understand, this in turn helps me refresh my knowledge and at the same time motivates me to learn more.
If you would like to learn python or just read stuff about it, follow the thread as I would try my best to be consistent in updating it with the simplest and brief concepts required of every beginner.
To start off programming with python you would need python (obviously) and an IDE (Integrated Development Environment).
The links on how to get python and pycharm IDE are below (i recommend pycharm cause its good for beginners and overall one of the best IDE's out there):

https://www.youtube.com/watch?v=Kn1HF3oD19c (python installation)

https://www.youtube.com/watch?v=XsL8JDkH-ec (pycharm installation)

PYTHON:
Python basically is a high-level programming language, that do what every other programming language does (give the computer instructions on how to run a task).
The first ever code that any aspiring programmer would ever right in python would be
print("hello world" ) ...... This is the simplest instruction anyone can give to a computer using python. It basically tells python to print an output result "hello world", and that's what it would do.
If you've written this code then congratulations!! kiss , you're about 1% ready to be a python programmer grin.
Re: Learn Python With Me by quickhubservice(op):
STRINGS AND VARIABLES:

message = "hello python lovers"

In the above we have two parameters namely the variable (message) and the string ("hello python lovers" ).
A variable in the simplest explanation is like a box we can use to store data (in this case a string value) in python to make it easier to carry out some tasks on those set of data later on.
A string is a collection of alphabets, words or other characters. You know a string cause it's in parenthesis.
So, from the above we have stored our string in the variable message meaning anytime we want to see our message displayed we just simply ask python to print(message), and we get our values displayed.
There are some rules guiding the use of variables that we should take note of like:
Don't use numbers before alphabets e.g. 1message, instead use message1 or message_1
Also spaces aren't allowed when defining variables instead use _ to separate your words.
Re: Learn Python With Me by quickhubservice(op): 12:22am On Sep 14, 2022
Now you know a bit about variables, let me show you how to perform some cool stuffs with it.
we can do some cool operations on the values stored in the variable without actually directly involving the set of data involved.
E.g.
message = "hello python lovers"
print(message)
>>> hello python lovers

print(message.title())
>>> Hello Python Lovers

print(message.upper())
>>> HELLO PYTHON LOVERS

print(f"john said {message.upper())".title())
>>> John Said HELLO PYTHON LOVERS

and many more.... The idea is that since programming is all about automation, we automate the whole process making it easier for us to use any set of data. when this message is saved in a variable, we can use it anytime without actually typing it. This can be useful when we begin working with other forms of data such as lists and dictionaries.
Re: Learn Python With Me by quickhubservice(op): 12:28am On Sep 14, 2022
METHODS:
from the above we got to see a bit of methods in action. A method is a function that belongs to an object. we see them and start using them from the beginning till whatever end python programming has as they are very important and are seen not only applied on strings but on variables, classes and other stuffs we will look at later on.
Examples include: .upper()
.Lower()
.append()
.remove() etc

APPLYING VARIABLES IN STRINGS:
To apply a variable to a string, we use the letter 'f' immediately before opening the parenthesis as done above in the examples giving. These is called the f strings. The f stands for format because python formats the string by replacing the name of any variable in a string with its value.

say we have two variables with two names of a person:

first_name = ("john" )
last_name = ("shit" )

we can use these variables in a string by telling python to:

print(f"he said his name is {first_name.title()} {last_name.title()}" )
>>> he said his name is John Shit

note: use braces{} around any variable you wanna use in any string
Re: Learn Python With Me by Yankee101: 4:08am On Sep 14, 2022
More power
Re: Learn Python With Me by quickhubservice(op): 10:04am On Sep 14, 2022
ADDING AND REMOVING WHITESPACES IN PYTHON:
Adding tabs:
So in programming generally whitespaces refers to any non printing character for example spaces, tabs(paragraphs) and end of line symbols.
To paragraph or as we say in programming to add a tab to any line of your code you use "\t".
E.g.
print(" \tpython" )
>>> python
This adds a tab(four line spaces) to the string value when its printed by python. Tabs are really useful and in some IDE's they are automatically applied when writing codes involving functions, classes etc, but when we want to use it like above, its mainly to make our codes readable.

Adding a new line:
we use "\n" to add a new line. Just as tab, its very useful in making our output results readable and organized.

print("\tpython" )
print("\n i love python".title())
>>> python

>>> I Love Python

Striping Whitespaces:
sometimes in python extra spaces in some of our input can cause some unwanted and confusing results in some of our projects. For example, "python", "python ", " python" and " python " aren't the same thing.
To remove any extra space on the right side of a string we use ."rstrip()"
For the left side we use "lstriP()"
for both sides we use just strip()

favourite_language = "python "
print(favourite_language.rstrip())
>>>"python"

The above method temporarily removes the extra space just this one time to permanently remove the extra space :

favourite_language = favourite_language.rstrip()

This would permanently remove any space in the string value. The method above works for all strip methods
Re: Learn Python With Me by Lopeademol(m): 10:08am On Sep 14, 2022
I prefer Cobra....Python is wild
Re: Learn Python With Me by quickhubservice(op): 11:03am On Sep 14, 2022
Lopeademol:
I prefer Cobra....Python is wild
cheesy cheesy
me too bro rattles are better
Re: Learn Python With Me by quickhubservice(op): 11:18am On Sep 14, 2022
NUMBERS:
In python we can carry out arithemetic operations on integers such as
addition (+)
subtraction ( - )
multiplication ( * )
division ( / )
power ( ** )

3 ** 2
>>> 9
3 * 2
>>>6
( 2 + 3 ) * 4
>>>20

any number with a decimal place in python is referred to as a float. Also when we divide two or more numbers the result is float.
integer/integer = float
integer/float = float
float/integer = float

CONSTANTS;
A constant is a variable whose value stays the same throughout the lifetime of the program its used in.
Using all capital letters indicate that a variable should be treated as a constant.

MAX_CONNECTIONS = 50000

The above will be saved as a constant

COMMENTS:
when writing codes as a programmer it's really good ethics to make your codes as readable and organized as possible. Comments are used to write notes in programs. These notes can be explanations of what each line or lines of a code does. Comments don't get executed by python.
In python the '#' indicate a comment
Re: Learn Python With Me by quickhubservice(op): 9:23pm On Sep 15, 2022
LISTS:
So lists as we all know can serve to hold some sets of information we need like when going to the markets or just maybe a list of stuffs we want to do in a day. Anyhow it is lists are used to store a collection of items or information. same applies in python, lists are collection of items in a particular order. Examples list of numbers 1 - 9, a list of people in your family etc.

This is how a list looks like in python:

vehicles = [ "motorcycles", "cars", "airplanes", "train", ]

The above is a list of vehicles and this is how we store lists in python. When we call this list or ask python to print it we get:

print(vehicles)
>>> [ "motorcycles", "cars", "airplanes", "train", ]

ACCESSING ELEMENTS IN A LIST:
We use index numbers to access items stored in any list that we create.
for example to access the first item on our list vehicle we use:

print(vehicles[0])
>>>"motorcycles"

Notice how we use the number 0 for the first item, this is how we index each item in out list starting with the number 0 and working our way to the last item.
we can also do what we call negative indexing to access values at the end of our lists. For example to call the last number we use "-1":

print(vehicles[-1])
>>>train

And just like when using positive numbers we will work our way to the first item.

We can also use some functions on individual items in our lists such as .upper(), .lower(), .title() and so on.
Note: to use this functions on the whole items in our list we use the "f" function when applying them.
for example:

print(f"{vehicles}".title())
Re: Learn Python With Me by lawrenzoo: 6:47am On Sep 19, 2022
Enjoying your teachings bro, still waiting for more.
Re: Learn Python With Me by EmemObong03: 9:35am On Sep 19, 2022
More please
Re: Learn Python With Me by quickhubservice(op): 12:01pm On Sep 19, 2022
Sorry I haven't updated this in a while ... Will do so later today. Have been occupied with work and still learning about this with the spare time I get.
1 Reply

Python With MYSQL: Registration Form In Python Using Tkinter And MYSQL DatabaseWho Wants To Learn Python With Me? 90 Days ChallengeLearn Python With Kash234

Chat GPT Article On Bola Ahmed TinubuWeb Developers In The House Please Help MeWho's Good At C++?