Aprende Inglés, Programación, AI y Ciberseguridad.

Antes:$249

Currency
$209
Suscríbete

Termina en:

02d

17h

43m

00s

5

Resumen en código del curso

En este post te dejaré mi resumen en código de todo lo que aprendí del curso, creo que ha quedado bastante bien. Lo he creado en inglés, porque estoy practicando ese idioma pero creo que será fácil de entender el resumen. Sin nada más que decir, aquí te lo dejo:

#variables
my_variable = 1
print(1)
my_variable = 3
print(my_variable)

#constanst variables
MY_CONSTASNT = 100#concatenate variables
name = "Ignacio"
lastname = "Crespo"
print(name + " " + lastname)

#type of data
my_int = 1
my_float  = 4.7
string = "Hi!"
char = 'c'
boolean = False
my_list = [5, 4, 3, 2, "hola", 5.4]
my_tuple = (3, 'c', True, 4.1)
dictionary = {
    'key1': 1,
    'key2': 2,
    'key': 3,
    'key4': 4
}

print(type(my_int))
print(type(my_float))
print(type(string))
print(type(char))
print(type(boolean))
print(type(my_list))
print(type(my_tuple))
print(type(dictionary))

#convert data to a different type#input(): ask the user to enter data.
text = input("Enter something: ")
print(f'You entered: {text}')

    #convert to whole number
whole_number = int(input("Enter a whole number: "))
print(f'You entered: {whole_number}')

    #convert to float number
float_number = float(input("Enter a float number: "))
print(f'You entered: {float_number}')

    #convert to string
a_number = 54
print("George is " + str(a_number) + " years old.")

    #convert to boolean
the_number = bool(input("Enter a boolean: "))
print(the_number)

#loops#while
LIMIT = 20

counter = 0while counter < LIMIT:
    print(counter)
    counter += 1#forfor i in range(10):
    i *= 2
    print(f'i multiplied by 2 equals {i}')

#conditionals
age = int(input("Enter your age: "))

if age > 17:
    print(f'You are {age} years old, you can pass')

elif age == 17:
    print(f'You are {age} years old, you can pass but without drinking alcohol.')

else:
    print("You are a minor, you can't pass.")

#functiondefsum(a, b):return a + b

defrun():
    a = int(input("Enter the first number: "))
    b = int(input("Enter the second number: "))
    numbers = sum(a, b)
    print(f'{a} + {b} = {numbers}')

if __name__ == '__main__':
    run()

#loop control#break
name = input("Enter your name: ")

for character in name:
    if character == 'ñ'or character == dictionary.values():
        break
    print(character)

    #continuefor my_number in range(10):
    if my_number % 2 == 0:
        continue
    print(my_number)

#length of a string
a_string = "Hi! My name is Ignacio!"
print(len(a_string))

#go through dictionaries
vowels = {
    'First': 'a',
    'Second': 'e',
    'Third': 'i',
    'Fourth': 'o',
    'Fifth': 'u'
}

print(vowels)

for key in vowels.keys():
    print(key)
    #allows us to show only the name of the keyfor vocal in vowels.values():
    print(vocal)
    #it only shows us the value of the key, without its key.for key, vocal in vowels.items():
    print(f'{key}: {vocal}')
    #shows the name of the key and its value#slices#slices allow us to divide the characters of a string in multiple ways
name = "Francisco"
print(name)
print(name[0 : 3]) 
print(name[1:7]) 
print(name[1:7:2])
print(name[1::3]) 
print(name[::-1])

#methods for strings
my_name = " ignAcio"
print(my_name)
    #upper(): converts all letters in the string to uppercase.
print(my_name.upper())
    #capitalize(): it only capitalizes the first letter of a string.
print(my_name.capitalize())
    #strip(): delete all the "junk" spaces (that is, what is left over).
print(my_name.strip())
    #lower(): lowercase all letters in a string.
print(my_name.lower())
    #replace():
print(my_name.replace('o', 'a'))
    #append():
print((my_name.append(4)))
    #pop(): delete a char based on its index
print(my_name.pop(2))
    #choice():
print(my_name.choice())
Escribe tu comentario
+ 2