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 Notes for Beginners....
Description: Python Programming Language Notes for Begineers, In this Notes I have Explianed about Python Datatypes, Operators, Conversions , Types of Conversions , How to Run Python Code

Document Preview

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


Python Programming
What is Python?
Python is a multipurpose programming language that can be used for a
variety of different tasks, such as automation, web development, and data
science
...




You need to install a code editor to write your own Python code
...


Running Python Code
To run Python code in PyCharm, we go to the run menu and select run, or
use the shortcut (ctrl+shift+r on a Mac)
...
Python is case sensitive so
make sure to use the correct case when coding
...
Python also has boolean
values that can be true or false
...
95
print(price)

Declare and Use Variables in Python
Here's a little exercise for you: imagine we want to write a program for a
hospital, so we're going to check in a patient named John Smith
...
I want you to declare a few variables to
store these values
...


Receiving User Input in Python
In Python, we have a built-in function called input() that we use to
read a value from the terminal window
...

Let's write a simple program to demonstrate this:
name = input("What is your name? ")print("Hello, " +
name)
When we run this program, it will prompt the user to input their name
...


Data Types in Python
There are three main data types in Python: numbers, strings, and booleans
...




Strings - This includes textual data
...


Converting Data Types in Python
Python has several built-in functions for converting the types of our
variables
...
")
In the above example, we use the int() function to convert
the birth_year string to an integer so we can subtract it from the
current year
...
5"float_num = float(num)print(float_num)
In the above example, we use the float() function to convert
the num string to a floating point number
...
In this tutorial, I'll show you a
bunch of cool things you can do with strings using Python for beginners
...
So, when we run
this program, you're going to see 1 on the terminal because the index is 1
...

first = float(input("Enter the first number: "))
We can also change this expression to first + second , which is
another way to write this piece of code
...


string = "Hello World"print(string
...
find('o')) # Output:
4print(string
...

string = "Python is a programming language for
beginners
...

print(10 + 3) # Output: 13
We also have an augmented assignment operator in Python that means
incrementing a variable by a value
...

x = 10 + 3 * 2 # Output: 16
Multiplication and division have a higher order, so they are evaluated first
...

x = 10 + 3 / 2print(x) # Output: 11
...
5
...
5
When we run x += 3 , we get 14
...
When we run x ==
13 , it will store False in the x variable
...
These operators are important for comparing values and
evaluating certain conditions
...
Another set of important operators are the logical operators,
used to evaluate complex rules
...
The following are comparison operators in Python:


Equal to: ==



Not equal to: !=



Greater than: >



Less than: <



Greater than or equal to: >=



Less than or equal to: <=

Logical Operators
Python uses logical operators to evaluate complex rules
...


If Statements
If statements in Python are used to make decisions in the program
...


To represent a block of code in Python, we use indentation instead of curly
braces
...

In Python, there are three logical operators:


The logical or operator returns true if at least one of the expressions are
true



The logical and operator returns true if both the expressions are true



The logical not operator inverts any value that it is given

Example
Let's take an example to understand the usage of these operators:
temperature = 25

if temperature > 30:

print("It's a hot day")

elif temperature > 20 and

temperature <= 30:
temperature > 10:

print("It's a nice day")
print("It's a bit cold")

elif
else:

print("It's a cold day")
In this sample code, if the temperature is:


Greater than 30, it's a hot day



Between 20 and 30, it's a nice day



Greater than 10, It's a bit cold



Less than or equal to 10, it's a cold day

Remember, the code will only execute if the expression inside the if or elif
statements are true
...

Comments in Python are added using the hash (#) symbol
...


Python Exercise
Let's spend 5 minutes on this exercise
...
When you're done, come back and
see my solution
...
So, we need to convert a
given string to uppercase
...
We can
see all the available functions or methods in a string object by typing dot
...

If the given string includes a lowercase "k", we should convert the weight
to pounds and print it on a terminal
...
45 to convert it to pounds, and
print the weight in pounds
...
"
If the "k" condition is not true, that means the weight was entered in
pounds
...
45, and print the weight in kilograms
...
"

While Loops in Python
In Python, we use while loops to repeat a block of code multiple times
...
But,
writing 1 million lines of code isn't a good approach
...

In every iteration of the loop, the value of "i" is incremented by one
...
In
this case, we multiply a number by a string to repeat that string
...


It will never terminate, and our program will continue running until it runs
out of memory
...


About the Instructor
If you want to learn more about Python, you may want to look at the
Python course offered by the instructor
...
You can find plenty of courses on web and mobile development
on the instructor's online coding school at codewithmosh
...

In Python, negative indices can be used to access elements in a list
...
To change an object at a
specified index, we use an assignment statement
...
This is how
lists are used in Python:


To get items in a list using negative index



To change an item at a given index



To access elements from the start index up to the end index but exclude
the end

In Python, objects like your phone, bicycle, or TV remote control have
strengths that allow you to operate them
...
Similarly, Python returns a list with an index that includes the
elements at index 0, 1, and 2
...
Lists are also objects, so they have
various methods for adding or removing items
...
If you want to
remove all items in the list, use the clear() method
...

When you want to iterate over a list and access each item individually, use
the built-in len() function
...
The implementation using the for loop is
the shortest and easiest to understand
...
We can pass a value, such as 5 , and it will
return a range object
...

Tuples in Python are similar to lists, and we can use for loops with any
object that represents a sequence of objects, including tuples
...
g
...



Title: Python Programming Notes for Beginners....
Description: Python Programming Language Notes for Begineers, In this Notes I have Explianed about Python Datatypes, Operators, Conversions , Types of Conversions , How to Run Python Code