GoConqr has a new look! Let us know what you think.

Flashcards

Python practice

Sara Rodríguez 1C25 English 36 cards

Cards in this deck (36)

  1. 1Converts a number stored in a string or integer into a floating point number, or a number with a decimal point.float
  2. 2Are positive or negative whole numbers with no decimal pointint
  3. 3Converts values to a text formstr
  4. 4It's used to represent the truth value of an expression. [T and F]bool
  5. 5Are used to store multiple items in a single variable. items are ordered, changeable, and allow duplicate values. [ ]Lists
  6. 6Are used to store multiple items in a single variable. Is a collection which is ordered and unchangeable. ( )Tuple
  7. 7Are used to store multiple items in a single variable. Is a collection which is both unordered and unindexed. { }Set
  8. 8Are used to store data values in key:value pairs. Is a collection which is ordered, changeable and does not allow duplicates. { }Dictionary
  9. 9If syntax?if b > a:
    print("b is greater than a")
  10. 10Is pythons way of saying "if the previous conditions were not true, then try this condition".elif
  11. 11Loop we can execute a set of statements as long as a condition is true.While
  12. 12Statement we can stop the loop even if the while condition is truebreak
  13. 13Statement we can stop the current iteration, and continue with the nextContinue
  14. 14This block lets you test a block of code for errors.try
  15. 15This block lets you handle the error.except
  16. 16This block lets you execute code, regardless of the result of the try- and except blocks.finally
  17. 17Loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set, or a string).for
  18. 18Is a special variable, which can hold more than one value at a time. [ ]Arrays
  19. 19Method to return the number of elements in an array.len
  20. 20Adds an element at the end of the listappend
  21. 21Clear syntaxclear()
  22. 22Removes the element at the specified position.pop
  23. 23Removes the first item with the specified valueremove
  24. 24Is like an object constructor, or a "blueprint" for creating objects.Class
  25. 25Create a classclass MyClass:
    x = 5
  26. 26Object exampleCreate an object named p1, and print the value of x:
    p1 = MyClass()
    print(p1.x)
  27. 27Use the ________ function to assign values to object properties, or other operations that are necessary to do when the object is being created__init__
  28. 28Rounds a number up to the nearest integermath.ceil()
  29. 29Returns E raised to the power of xmath.exp()
  30. 30Returns the absolute value of a numbermath.fabs()
  31. 31Rounds a number down to the nearest integermath.floor()
  32. 32Returns the remainder of x/ymath.fmod()
  33. 33Returns the mantissa and the exponent, of a specified numbermath.frexp()
  34. 34TypeError>>> '2'+2
    Traceback (most recent call last):
    File "", line 1, in
    '2'+2
    TypeError: must be str, not int
  35. 35ValueError>>> int('xyz')
    Traceback (most recent call last):
    File "", line 1, in
    int('xyz')
    ValueError: invalid literal for int() with base 10: 'xyz'
  36. 36SyntaxError>>> while True print('Hello world')
    File "", line 1
    while True print('Hello world')

Information

Description
Flashcards on Python practice, created by Sara Rodríguez 1C25 on 15/08/2021.
Views
19
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?