Garantie de satisfaction à 100% Disponible immédiatement après paiement En ligne et en PDF Tu n'es attaché à rien 4.2 TrustPilot
logo-home
Notes de cours

BEST Python+Syntax+Cheat+Sheet+Booklet (Detailed)

Note
-
Vendu
-
Pages
16
Publié le
09-04-2022
Écrit en
2022/2023

BEST PYTHON SYNATAX XHEATSHEET

Établissement
Cours










Oups ! Impossible de charger votre document. Réessayez ou contactez le support.

École, étude et sujet

Établissement
Cours

Infos sur le Document

Publié le
9 avril 2022
Nombre de pages
16
Écrit en
2022/2023
Type
Notes de cours
Professeur(s)
Angela yu
Contient
Toutes les classes

Sujets

Aperçu du contenu

PYTHON CHEAT SHEET
100 DAYS OF CODE
COMPLETE PROFESSIONAL
PYTHON BOOTCAMP

BASICS


Print

Prints a string into the console. print("Hello World")


Input

Prints a string into the console, input("What's your name")
and asks the user for a string input.



Comments

Adding a # symbol in font of text #This is a comment
lets you make comments on a line of code. print("This is code")
The computer will ignore your comments.



Variables

A variable give a name to a piece of data. my_name = "Angela"
Like a box with a label, it tells you what's my_age = 12
inside the box.



The += Operator

This is a convient way of saying: "take the my_age = 12
previous value and add to it. my_age += 4
#my_age is now 16



www.appbrewery.com

, PYTHON CHEAT SHEET
100 DAYS OF CODE
COMPLETE PROFESSIONAL
PYTHON BOOTCAMP
DATA TYPES


Integers

Integers are whole numbers. my_number = 354


Floating Point Numbers

Floats are numbers with decimal places. my_float = 3.14159
When you do a calculation that results in
a fraction e.g. 4 ÷ 3 the result will always be
a floating point number.


Strings

A string is just a string of characters. my_string = "Hello"
It should be surrounded by double quotes.



String Concatenation

You can add strings to string to create "Hello" + "Angela"
a new string. This is called concatenation. #becomes "HelloAngela"
It results in a new string.



Escaping a String

Because the double quote is special, it speech = "She said: \"Hi\""
denotes a string, if you want to use it in print(speech)
a string, you need to escape it with a "\"
#prints: She said: "Hi"


www.appbrewery.com

, PYTHON CHEAT SHEET
100 DAYS OF CODE
COMPLETE PROFESSIONAL
PYTHON BOOTCAMP



F-Strings

You can insert a variable into a string days = 365
using f-strings. print(f"There are {days}
The syntax is simple, just insert the variable in a year")
in-between a set of curly braces {}.




Converting Data Types

You can convert a variable from 1 data n = 354
type to another. new_n = float(n)
Converting to float:
float() print(new_n) #result 354.0
Converting to int:
int()
Converting to string:
str()




Checking Data Types

You can use the type() function n = 3.14159
to check what is the data type of a type(n) #result float
particular variable.




www.appbrewery.com
€7,07
Accéder à l'intégralité du document:

Garantie de satisfaction à 100%
Disponible immédiatement après paiement
En ligne et en PDF
Tu n'es attaché à rien

Faites connaissance avec le vendeur
Seller avatar
hppavilion

Faites connaissance avec le vendeur

Seller avatar
hppavilion IIT BOMBAY
S'abonner Vous devez être connecté afin de suivre les étudiants ou les cours
Vendu
0
Membre depuis
3 année
Nombre de followers
0
Documents
2
Dernière vente
-

0,0

0 revues

5
0
4
0
3
0
2
0
1
0

Récemment consulté par vous

Pourquoi les étudiants choisissent Stuvia

Créé par d'autres étudiants, vérifié par les avis

Une qualité sur laquelle compter : rédigé par des étudiants qui ont réussi et évalué par d'autres qui ont utilisé ce document.

Le document ne convient pas ? Choisis un autre document

Aucun souci ! Tu peux sélectionner directement un autre document qui correspond mieux à ce que tu cherches.

Paye comme tu veux, apprends aussitôt

Aucun abonnement, aucun engagement. Paye selon tes habitudes par carte de crédit et télécharge ton document PDF instantanément.

Student with book image

“Acheté, téléchargé et réussi. C'est aussi simple que ça.”

Alisha Student

Foire aux questions