How to Use Tuples, Arrays and Imported Modules in Python! Beginner Lesson

LeMaster Tech
183 followers
10 Video Views·Apr 23, 2025
This is the best place to learn and practice python skills for beginners looking to get started with Python! Learn how to create tuples, arrays, import modules and tricks and tips for using python!!
This is episode 7 in an introduction to python series coming from LeMaster Tech.
Be sure to give us a like, drop a comment, or subscribe to the channel for more content like this!
The previous video:
https://www.youtube.com/watch?v=uUee3XM1wuw
python download:
https://www.python.org/downloads/
pycharm download for windows:
https://www.jetbrains.com/pycharm/dow...
hello and welcome back to the channel
this will be video seven in our python
tutorial series so if you missed the
first few on installing setting up
python and pycharm your first couple
programs and functions
uh getting user input for loops while
loops thing like things like that be
sure to go back and check them out if
those are concepts you're unfamiliar
with as that's really important for
laying in a strong foundation in python
today's video is a little bit different
it's going to be just some things you
should know about python that haven't
really been discussed in detail in past
videos some tips and tricks that can
help you with some syntax things you
might not be familiar with and
help you
code a little bit cleaner and a little
more efficiently as well as hopefully
answer some of the faqs there are around
python
so
this code's a little bit different
because it's not really intended to run
it's intended to teach and it's already
constructed just so that i have
everything right in front of me to talk
about
the first thing i want to talk about is
importing modules into your code
so
you see right here the first rung i have
after my title is import math
now this is the the import statement is
how you bring functionality that's not
just in the
core
functionality of python but it's in
these additional packages so i have two
different modules that i'm bringing into
this function
i'm bringing in math and i'm doing it
this way where i just import the entire
package
and then
once i need to
use it i do math dot the piece that i
need and this is how you would use the
square root function inside the math
package but then the other way to do
imports is you do from
the module that you're importing and
then you actually say what it is that
you want to use so from random import
rand int which is how you use the random
integer function where you give it a
range of integers and it returns you a
random one inside of there
so these are the two different ways you
can import modules
in a python function they're both valid
it's just whether or not you want to
call the actual module further down in
your program or not
both equally valid
next thing and this is very quick i just
want to be clear this is a typical
python comment this is the the pound
sign followed by your text grayed out
this is how python comment goes you've
probably seen it in my videos or other
people's videos prior but if it was
never explained to you this is how you
also could make an entire rung of code
irrelevant so if you're getting errors
and you need to see the code around it
running but you think that that rung is
giving you trouble you can actually do
what's called commenting it out or
bypassing it with a pound sign hash key
whatever you call this identifier
um
but yeah so that's a comment that was
just a brief thing i wanted to
clarify on before going forward the next
is the indentation schematic inside
python i know when i've created four or
while loops or functions in the past
i've just done the indenting
um and kind of said you know trust me
but when you do a for loop or you do a
while loop it needs to be one
indentation inside that for loop in that
while loop
so what you need to know is
even when you create a loop inside of a
loop and a loop inside of a loop inside
of a function
it doesn't matter how many layers deep
you go the way python knows that code is
inside of something else
is
nesting
code related to
related
related to that
operation
inside
by one tab
so it
you can use spaces if you get the exact
right number of spaces
but it's just better to do a tab python
needs to see it at a certain indentation
level and will actually throw an error
if it sees the wrong indentation level
so that's true for
for loops while loops and functions you
have to put the related code one tab
inside and then if you put a loop inside
of the loop you have to go one tab
further in
then just a couple data types that i
haven't talked about prior because they
don't really come up that often unless
you're creating a program for something
very specific in which case you would
probably be looking up these data types
anyways
python has what's called a tuple tuple
e t-u-p-l-e
and it's just a it's two values
separated by a comma this is obviously
really common for coordinates is
probably the most common one
but any scenario where you would have
two affiliated numbers it's called a
tuple
they come up occasionally in python and
the important thing to know about them
is you cannot modify inside of those you
can't take one piece of a tuple out and
do operations with it and stuff it back
in um they're they're in a
inalienable they cannot be overwritten
or modified and that's just
um
a python rule about tuples and that's
how it is i mean you'll see them you'll
start seeing some applications for them
especially as you do practice problems
or create your first few projects but
not something that comes up a ton and
for now if you just kind of know it
exists know what it is and no really
coordinates are going to be your most
frequent time you would see these
um you really know enough to get started
so the next is arrays and um an array is
definitely something you might use
uh in a scenario where you would say
have a list and then you have multiple
entries of those lists
um so you can see here i've created an
array by putting a list
inside of another list and separating
the lists by commas so what we've
actually done is we've said well we've
got this row of three values and then
the middle row and then the bottom row
and there's a few different ways that
you can call
arrays obviously you can make this any
size you want
but
the way you call arrays is you put their
indices in square brackets and so this
here is just calling all of row two
but here i'm actually saying row one
column two and so you'll see when i
print those two things out
actually this is good you can see all
four of the things i have printing so
here you see the math dot square root of
25 we got five obviously we got a random
integer from one to ten and we got six
and then we got
i'm sorry the
arrays like most codes start counting
from zero so this is actually row zero
as the code sees it by indices so when
we print all of row two we're actually
saying zero one two
so we get all
of row two which is three three three
but then here we're saying row one so
zero one
and then value two which actually to
clarify we should probably make that
something different so you can see
we're getting
this value when we do one and then two
so you can either do just a row or you
can do row then column
um and reference a specific element
inside an array
um
so those are really just a few things
that i felt like grouping together
they're not really affiliated with one
another but they're important to know
especially as you create elaborate
programs and if you're going to become
really proficient with python and use it
in any sort of advanced method you need
to know these things even though they
might not come up every day some of them
definitely will and depending on your
application you never know which one of
these pieces of information you're going
to need
so hopefully you found some of that
informative obviously there's no way i
can catch every scenario and every piece
of info you might need but if you do
have a specific question feel free to
leave it in the comments and i'll try to
get back to you as soon as i can if you
found this information uh informative
and uh you'd like to
give it a like and and subscribe to the
channel i appreciate that
and as always thanks for checking it out
and uh see you next time thanks bye
