• ¿Documento equivocado? Cámbialo gratis
  • Escrito por estudiantes que aprobaron
  • Inmediatamente disponible después del pago
  • Leer en línea o como PDF
Vender
¿Dónde estudias?
Tu idioma
Document preview thumbnail
Vista previa 4 fuera de 68 páginas
Notas de lectura

Python language class notes (basic to advanced)

Document preview thumbnail
Vista previa 4 fuera de 68 páginas

My detailed material include essential libraries like Pandas and NumPy for data manipulation and analysis, along with core Python concepts, file handling, object-oriented programming, and advanced modules. Perfect for students, these notes simplify complex topics with clear explanations, practical examples, and guides. Learn how to handle datasets, perform mathematical computations. Whether you’re a beginner or preparing for exams, these notes are tailored by me to boost your understanding and save time!"

Vista previa del contenido

Programming with Python
notes basic to advanced with
coding challenges
Basic

Introduction:

Python is a very simple language, and has a very straightforward syntax. It encourages
programmers to program without boilerplate (prepared) code. There are two major
Python versions, Python 2 and Python 3. Python 2 and 3 are quite different. This tutorial
uses Python 3, because it more semantically correct and supports newer features.


Install Jupyter Notebook[2]
n this machine learning project for beginners, we will use Jupyter Notebook for the
development. Let’s see steps for the installation and configuration of Jupyter Notebook.

Using pip python package manager you can install Jupyter notebook:
In [ ]:
pip3 install notebook

And that’s it, you have installed jupyter notebook

After installing Jupyter notebook you can run the notebook server. To run the notebook,
open terminal and type:
In [ ]:
jupyter notebook

It will start the notebook server at http://localhost:8888
In [ ]:
!git clone https://github.com/hussain0048/Python.git

,1- Hello, World!
The simplest directive in Python is the "print" directive - it simply prints out a line (and
also includes a newline, unlike in C).For example, one difference between Python 2 and 3 is
the print statement. In Python 2, the "print" statement is not a function, and therefore it is
invoked without parentheses. However, in Python 3, it is a function, and must be invoked
with parentheses.
In [ ]:
#To print a string in Python 3, just write:
print("This line will be printed.")
In [ ]:
print("Goodbye, World!")
Goodbye, World!



2- Indentation
Python uses indentation for blocks, instead of curly braces. Both tabs and spaces are
supported, but the standard indentation requires standard Python code to use four spaces.
For example
In [ ]:
x = 1
if x == 1:
# indented four spaces
print("x is 1.")
In [ ]:
x = 1
if x == 1:



3 - Variables and Types
Python is completely object oriented, and not "statically typed". You do not need to declare
variables before using them, or declare their type. Every variable in Python is an object.

This tutorial will go over a few basic types of variables.



3.1 Numbers
Python supports two types of numbers - integers and floating point numbers. (It also
supports complex numbers, which will not be explained in this tutorial).

,To define an integer, use the following syntax:
In [ ]:
myint = 7
print(myint)
In [ ]:
#To define a floating point number, you may use one of the following
notations:
myfloat = 7.0
print(myfloat)
myfloats = float(7)
print(myfloats)

3.2- Strings
Strings are defined either with a single quote or a double quotes.The difference between
the two is that using double quotes makes it easy to include apostrophes (whereas these
would terminate the string if using single quotes)
In [ ]:
mystring = 'hello'
print(mystring)
mystring = "hello"
print(mystring)



4 -Lists
Lists are very similar to arrays. They can contain any type of variable, and they can contain
as many variables as you wish. Lists can also be iterated over in a very simple manner. Here
is an example of how to build a list.
In [ ]:
mylist = []
mylist.append("a")
mylist.append("b")
mylist.append("c")
print(mylist[0]) # prints 1
print(mylist[1]) # prints 2
print(mylist[2]) # prints 3
In [ ]:
# prints out 1,2,3
for x in mylist:
print(x)
In [ ]:
#Accessing an index which does not exist generates an exception (an error).

, mylist = [1,2,3]
print(mylist[10])



5- Basic Operators
This section explains how to use basic operators in Python.

5.1- Arithmetic Operators
Just as any other programming languages, the addition, subtraction, multiplication, and
division operators can be used with numbers.
In [ ]:
number = 1 + 2 * .0
print(number)
2.5
In [ ]:
print(type(number))
In [ ]:
# Another operator available is the modulo (%) operator, which returns the
integer remainder of the division. dividend % divisor = remainder
remainder = 11 % 3
print(remainder)
2
In [ ]:
# Using two multiplication symbols makes a power relationship.
squared = 7 ** 2
cubed = 2 ** 3
print(squared)
print(cubed)

5.2 -Using Operators with Strings
Python supports concatenating strings using the addition operator:
In [ ]:
helloworld = "hello" + " " + "world"
print(helloworld)
hello world
In [ ]:
lotsofhellos = "hello" * 10
print(lotsofhellos)
hellohellohellohellohellohellohellohellohellohello

Información del documento

Subido en
11 de enero de 2025
Número de páginas
68
Escrito en
2024/2025
Tipo
Notas de lectura
Profesor(es)
David j. malan
Contiene
Todas las clases
$8.77

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Vendido
0
Seguidores
0
Artículos
1
Última venta
-



Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes