Search for notes by fellow students, in your own course and all over the country.

Browse our notes for titles which look like what you need, you can preview any of the notes via a sample of the contents. After you're happy these are the notes you're after simply pop them into your shopping cart.

My Basket

You have nothing in your shopping cart yet.

Title: python programming language
Description: python programming language for freshers in which learn python basics

Document Preview

Extracts from the notes are below, to see the PDF you'll receive please use the links above


Python for Beginners - Learn Python in 1 Hour
Programming with Mosh
Iphone or iPad you need to install a couple of other things first so you go to the
App Store and search for Pycharm
...

Now
...
Here in
your downloads folder
...
py file
...

The first thing you 're going to do is create a new project so let's do that by clicking
on this green plus sign here in your project explorer window and type in Python
...
Now let's choose a location for your project so
we're going to choose a folder on our computer called projects and then click on
the create Button Now let's change some settings inside of Pycharm
...
To want to do is change the language of your project to Python,
So inside of pycharm
...
Now next thing you 'r e
going to want to do is set up your project folder so inside of pycharm go to File >
Settings > Project Structure and in the Project Folder section click on the Browse
button and then select the folder where you want your project files to live so now
Your project is set up and ready to go all right let's start writing some code
...
In
Python
...
py file and enter this code here
...
py now let's run our program by clicking on this green run button
here inside of pycharm and you'll see that our program has printed out [UNK]
world!" all right that's our first simple code block in Python now Let's take a look at
some more code blocks in Python
...
py file again and enter this code def [UNK] [UNK] world!")
all right so we've defined a function called say —hello() and inside of say —hello()
we're going to print out [UNK] world!" now let's save our file once again say we
want to declare a variable called price
...
We would put a colon and then the value of that variable
...
99
...
We can do that by simply writing print price and then after that we would
put a period and then the value of the variable
...
99 alright
...
We
can do that by simply typing new value for price and then after that we would type

a colon and then the new value of the variable
...
00 alright
...
We can do that
by simply typing delete price and then after that we would type a period and then
hit enter so In this case, the code would delete the variable called price Alright
...
Let's say we have a list of items and we want to display
...
We would type for item in list, and then after that we
would type parenthesis, then the list item and then after that hit enter so In this
case, the code would run for each item in the list called list and then it would go
inside the parentheses and it would assign the item inside those parentheses to the
variable called item
...
You could do that by simply typing different values for
parenthesis
...
So now you
understand how to use a for loop alright
...
Functions are blocks of code that you can use in your python prog rams
to simplify your code or to make it more powerful
...
Okay now let's say we
wanted to call this function inside our for loop so to do that we would type
square(12
...
In this case the code
would run and it declare and use variables in python
...
The age of John Smith is 1990
okay
...
In addition to reading values from the user, we also have the ability
to write values to the user
...
Let's run our program and see what happens so please enter your
message so we get this message now
...
So we use the while loop so we
type while True which means while the condition is True
...
So now
let's add a counter to our program
...
So we add a variable called counter and set it

to 1
...
of it, you will see that our
while loop condition has been met four times
...
If you run our program again and type exit out of it
...
Now If you run our program again and type exit out of it, you will
see that our while loop condition has been met nine times now final ly let's add
another counter and set it to 4
...
If you run our program again and type exit
out of it
...
So this
is how we can use the while loop in Python to write a value to the user
...
THe passage discusses how an error occurred in a program
...
TO solve the problem, the author converted the string to an integer and
solved the problem
...
1 and here 's the result In
...
THe first number is read into a variable, and the
second number is read into a second variable
...
numeric
representations
...

One way to solve This problem would be to use the int function, which would
convert both numbers to integers
...
Since we're dealing with strings, we
need to use the float function instead
...
Since we're not required to use
the float function, we could have just called it at the time
...
IN conclusion,
...
The first step is to read in the first number into a variable, and
the second step is to read in the second number
...
Finally, the sum of the two numbers is displayed on the
terminal
...
You should see two now
...
So if we wanted to
find the character at index 3 in our string
...
find(3) and as Ia you
can see that function returned the value 4
...
Now let's take a look at one last function called
split and this function will take a string as input and it will split that string into an
array of characters
...
split() as ia, you can see that function has

divided our string into an array of three characters
...
to do
some math
...
So in this case
our number is 5
...
This is a really useful
function because it allows us to do basic math operations on strings without having
to worry about the individual characters in the string okay so that's all for today
folks thank you for watching look at the first one so in this case, we have division
with one slash so what this operator is going to do is it 's going to divide the first
number by the second number and that's it so let 's print 5 divided by 2
...
is going to be divided by 2
...
Now let's look at
the second division operator
...
This is going to print 3
because 10 is going to be divided by 3
...
Now let's look at a final
example
...
So in Python
...
This is going to print 2
...
Which is 2
...
Now what we want to do is w e
want to compare or compare these
...
So
this is equal to or it's the same as the regular assignment operator, but it also
works with comparison operators
...
If these
two values are equal and False if they're not equal
...
Let me ask you another
question suppose I have a variable called x and I set it to 10
...
Now what do you
think is the result of this expression
...
The answer is 15
...
5 plus
5
...
5
...
Then we 're
going to have another Boolean expression price less than 30 and the result of this
expression is also going to be false because price is 10
...
So these are the five comparison operators that you 'll see in
Python
...
So for
example, if we wanted to compare the value of x to 3, we could use greater than or
equal to followed by less than or equal to and then we could use the equality
operator right after that so that's a little bit more detail on these comparison
operators in Python
...
Our if statement and let's say if temperature is not
greater than 30, We want to print a message saying it 's not a hot day, so we type if
then we type a condition and this is where we use our comparison operators, So we
type temperature not greater than 30
...
So the code that we write over here will be executed If this condition
is true otherwise it's not going to be executed
...
It 's not a hot day and by the way note that here i've surrounded the string
with double quotes
...
with single quotes If I typed it 's not a hot day
look Python gets confused because it thinks this single code represents the end of
our string, so it doesn't recognize the subsequent characters okay so that 's why we
use double quotes here so we can have an apostrophe in our string, so it 's not a
hot day Now If I press enter again
...
If this condition is true
...
We press enter and then press shift and tab
...
So the code that we write here will always get executed no matter what
whether this condition is true or not okay
...
We present a block of code using curly
braces
...
In python we do n't have curly braces
...
These two lines are indented and that means
they are part of this block of code
...
So we type if then we type another condition and this is
where we use
...
Then so we add an equals sign and see what happens when I press
enter now
...
So the
code that we write over here will be executed only if this condition is true in
kilograms
...
It tells me to multiply the weight by 2
...
So I type m and press enter now
...
So I type P and press enter now
...
So I type P and press enter again
...
If
statement here we have three conditions
...

The second is that the weight is in pounds and the third is that the weight is
between 170 and 220
...
If any of these conditions are met, then we're going to
print a message saying the weight is in this range okay, so what we have here is a
range of weights from 170 to 220, so we can print it says the weight is in this range
...
THe insights that can be gleaned from this passage
are as [UNK] [UNK] while loop can be used to repeat a block of code multiple times
...
[UNK] the variable i within the while loop is necessary for it to keep track

of the counter
...
So in this case
...
an asterisk to indicate that I want
to print every element in the list
...
So here we are creating a
new variable called students and we're assigning it the value of a list, which is a list
of strings
...
Now let me run this program and we see that it's printing out all
the students in my class
...
So here we are cre ating a new
variable called grades and we're assigning it the value of a list, which is a list of
floats
...
My class okay now Let me create a new fi le
called practice
...
So first I am going to
import the math module so we can use mathematical operations like addition,
subtraction,, multiplication, and division In
...
You learn about lists, which
are used for representing a list of objects
...

can use them to store multiple items in a single variable, but the difference is that
tuples are immutable
...
We can do this by typing (2,
3, 5) and this is going to create a tuple that contains the values 2, 3 and 5
...
We would type (2, 3, 5)
and this would change the value of the first item in the tuple
...
You go so tuples are kind of like lists, but they
are immutable so you can't
...
So for example, let's say we want to
create a function that takes two tuples as input parameters and it's going to print
out the sum of the items in each tuple okay So let's say we want to create a
function called add —two —tuple that takes two tuples as input parameters and it's
going to print out the sum of the items in each tuple okay
...

We can type def add —two —tuple and then inside of add —two —tuple
...
a tuple consisting of one item and a tuple consisting of two items now
...
If we wanted
to call our add —two —tuple function from within our main script
...
add —two —tuple( (1,
2), (3, 4)) now you might be wondering how you're supposed to pass two tuples as
input parameters to a function if they're not stored in variables like numbers or
strings right well
...
So for example, if we Tuples are
immutable, and can't be changed once they're created
...
But they are unchangeable once they're created
...
IF
...
IF
Title: python programming language
Description: python programming language for freshers in which learn python basics