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