Ajude a dar forma ao GoConqr. O que a gente deve adicionar?

Notas

Python

Santiago Navas Python 1º de ESO Espanhol 3 páginas

#Nombres de variables permitidos: myvar = "John" my_var = "John" _my_var = "John" myVar = "John" MYVAR = "John" myvar2 =…

Conteúdo das notas (3)

Página 1

#Nombres de variables permitidos:

myvar = "John"

my_var = "John"

_my_var = "John"

myVar = "John"

MYVAR = "John"

myvar2 = "John"

#Nombres de variables bloqueados:

2myvar = "John"

my-var = "John"

my var = "John"

#Se puede establecer más de una variable en la misma línea

x = y = z = "Orange"

print(x)

print(y)

print(z)

#Se pueden hacer variables globales y privadas dentro de una función

x = "awesome"

def myfunc():

x = "fantastic"

print("Python is " + x)

myfunc()

print("Python is " + x)

#Estos son los tipos de variables

Text Type: str

Numeric Types: int, float, complex

Sequence Types: list, tuple, range

Mapping Type: dict

Set Types:set, frozenset

Boolean Type: bool

Binary Types: bytes, bytearray, memoryview

#Se puede obtener el tipo de variable con el siguiente comando:

x = 5

print(type(x))

#Estos son los tipos de variables mejor explicado:

x = "Hello World" str

x = 20 int

x = 20.5 float

x = 1j complex

x = ["apple", "banana", "cherry"] list

x = ("apple", "banana", "cherry") tuple

x = range(6) range

x = {"name" : "John", "age" : 36} dict

x = {"apple", "banana", "cherry"} set

x = frozenset({"apple", "banana", "cherry"}) frozenset

x = True bool

x = b"Hello" bytes

x = bytearray(5) bytearray

x = memoryview(bytes(5)) memoryview

#Nombres de variables permitidos: myvar = "John" my_var = "John" _my_var = "John" myVar = "John" MYVAR = "John" myvar2 =…

Página 2

#Imprimir algo random entre 2 números:

import random

print(random.randrange(1,10))

#Se pueden imprimir varias líneas

a = """Lorem ipsum dolor sit amet,

consectetur adipiscing elit,

sed do eiusmod tempor incididunt

ut labore et dolore magna aliqua."""

print(a)

#Esto imprimiría la segunda letra de la variable "a" (si quiero imprimir la primera, pon 0 no 1)

a = "Hello, World!"

print(a[1])

#Imprimir algo random entre 2 números: import random print(random.randrange(1,10)) #Se pueden imprimir varias líneas a =…

#Imprimir algo random entre 2 números: import random print(random.randrange(1,10)) #Se pueden imprimir varias líneas a =…

Página 3

One line if statement: if a > b: print("a is greater than b") Test if a is greater than b, AND if c is greater than a: a =…

One line if statement:

if a > b: print("a is greater than b")

Test if a is greater than b, AND if c is greater than a:

a = 200

b = 33

c = 500

if a > b and c > a:

print("Both conditions are True")

Test if a is greater than b, OR if a is greater than c:

a = 200

b = 33

c = 500

if a > b or a > c:

print("At least one of the conditions is True")

Informações

Descrição
1º de ESO Python Notas sobre Python, criado por Santiago Navas em 14-02-2020.
Criado por
Santiago Navas
Visualizações
6
Avaliação

Fale Conosco

Sobre o que é sua mensagem?

O que a gente deve adicionar?