O GoConqr está de visual novo! Conte para nós o que você achou.

Flashcards

Python commands

Maruuuko W Python commands Marukos Abi Alemão 35 flashcards

Flashcards do conjunto (35)

  1. 1Package installerpip install
  2. 2Write something in the consol(easy way)print(str("x"))/print(int(x))
  3. 3How to check what type a command is?for Ex.:type("x") ---> class str
  4. 4What is the output of: type("Hello!")class 'str'
  5. 5What is the output of: type(10)class 'int'
  6. 6What is the output of: type((10, 20, 30))class "tuple"
  7. 7What is the output of: type([10, 20, 30])class 'list'
  8. 8What's the key diffrence between of a 'tuple' class and a list?Tuples = immutable
    List = mutable
  9. 9For what stands 'int'? (And give an example)int = integer
    For ex.: −3, −2, −1, 0, 1, 2, 3,...
    No integers are for ex.:- 1.43, 1 3/4, 3.14,...
  10. 10Is 0 an integer?Yes
  11. 11Example for float numbers:133.5, 2897.11, 30.0, 3,8
  12. 12What does this do?: for i in range(10): print(i)output:
    0
    1
    2
    3
    4
    5
    6
    7
    8
    9
  13. 13What does this do?: for i in range(10,20,2): print(i)10
    12
    14
    16
    18
    --> 2 steps (Begins at 10)
  14. 14how to round sth.?round(number, digits)
  15. 15What doe this do?: x = round(20.7907, 2) print(x)output:
    20.79
  16. 16How to create an user input?x = input("Userinput")
  17. 17How to find the length of an object?len(x)
  18. 18What does this do?: x = "Hello World" print(len(x))output:
    11
  19. 19What does this do?(user wrote Hey): x = input("Write a word: ") print("You input is "+str(len(x))+" letters long")Output:
    "Your input is 3 letters long"
  20. 20Would this work?: x = input("Write a word: ") print("You input is "+len(x)+" letters long")No, len(x) is an int. So it hast to be transformed to a string (with str()).
    Correct code:
    x = input("Write a word: ")
    print("You input is "+str(len(x))+" letters long")
  21. 21How to create a loop? (simple way)With 'for' or 'while'
  22. 22Easy way to create an "infinitive" loop:while True:
    ....
  23. 23What's the output?: x = ["B","Hello", "Made by MRK", "C"] for k in x: print(k)output:
    B
    Hello
    Made by MRK
    C
  24. 24Would this code work?: x = ["B","Hello", "Made by MRK", "Cool", 1, 2] for p in x: print(p)Yes, althoug there is an int, it has no inpact
  25. 25What's the output for this code? x = ["B","Hello", "Made by MRK", "Cool", 1, 2] for i in x: print(x)['B', 'Hello', 'Made by MRK', 'Cool', 1, 2]
    ['B', 'Hello', 'Made by MRK', 'Cool', 1, 2]
    ['B', 'Hello', 'Made by MRK', 'Cool', 1, 2]
    ['B', 'Hello', 'Made by MRK', 'Cool', 1, 2]
    ['B', 'Hello', 'Made by MRK', 'Cool', 1, 2]
    ['B', 'Hello', 'Made by MRK', 'Cool', 1, 2]
    --> in the list 'x' are 6 values: so x will be get printed (my english is fucked up btw xD)
  26. 26How to check if a value is a string?for example:
    x = "MadebyMRK"
    print(str.isalnum())
    Output:
    True
  27. 27What's the output: x = "Made by MRK" print(x.isalnum())Output:
    False
    (There is a 'space' between the word--> no string)
  28. 28How to capitalize a function?for example:
    x = "hey"
    print(x.capitalize())
  29. 29What's the output? txt = "My Name is Maruko" x = txt.find("is") print(x)The output is: 8
    --> The str "is" is at the 9th "position" of the string --> computer always begin at the position "0" ---> just count the positon and do -1 ---> 9 - 1 = 8
  30. 30What's the output? txt = "My Name is Maruko" x = txt.find("MRK") print(x)The output is: -1
    --> If the computer isn't able to find a str that matches with your value, it will always respond with -1
  31. 31How to count sth.?with the count function
  32. 32What's the output: string = "Emma is good developer. Emma is a writer" print("Given sentences: "+string) print("The Name Emmea apperas: "+str(string.count("Emma"))+" times!")The output:
    Given sentences: Emma is good developer. Emma is a writer
    The Name Emmea apperas: 2 times!
  33. 33How to center sth. (Space missing space on each side)With:
    str = "x"
    MRK = str.center(5, "-")
    print(MRK)
    Output:
    --x--
  34. 34How to remove an elemnt from a specified position in the list?pop()
  35. 35How to sort elemnts in a list?sort()

Informações

Descrição
Hey, I prepared for every (at least I tried for every command °-° ) function a github python file. Feel free to review these commands and to give some feedback (I created them to train for myself actually). Cya and have fun! https://github.com/Maruuuko/python_command_index_cards
Criado por
Maruuuko W
Visualizações
7
Avaliação

Fale Conosco

Sobre o que é sua mensagem?

O que você acha do novo visual?

Você gostou?