





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






⩥ 12. Answer: integer ⩥ 1.2. Answer: float ⩥ 'twelve'. Answer: string ⩥ "twelve". Answer: string ⩥ True or False. Answer: Boolean value ⩥ type(). Answer: determines type of an object (integer, boolean, etc) ⩥ int(). Answer: converts to integer object ⩥ float(). Answer: converts to float object ⩥ str(). Answer: converts to string object
⩥ print(). Answer: displays a message ⩥ +. Answer: addition (integer) or concatenation (string) ⩥ -. Answer: subtraction ⩥ **. Answer: power of ⩥ %. Answer: modulus, remainder ⩥ /. Answer: division, always results in float ⩥ //. Answer: division, always results in integer ⩥ =. Answer: assignment operator ⩥ +=. Answer: reassignment operator, adds ⩥ - =. Answer: reassignment operator, subtracts ⩥ *=. Answer: reassignment operator, multiples
⩥ count(). Answer: totals number of times an argument is found within a predefined value ⩥ format(). Answer: inserts variable data in a string ⩥ def. Answer: keyword used to create functions ⩥ def myfunction():. Answer: syntax for function declaration ⩥ return. Answer: defines output of a function ⩥ if age < 16:. Answer: creates an if statement ⩥ else:. Answer: else statement, used in conjunction with if statement or if/elif statement ⩥ elif age >= 16 and age <= 18:. Answer: elif statement, used in conjunction with if statement ⩥ True and False. Answer: False: and operation will always be false unless both sides are true
⩥ True or False. Answer: True: or operation will always be true unless both sides are false ⩥ not(True and False). Answer: True: Boolean not operation will produce the inverse value. ⩥ myNumbers = [1, 4.8, 7, 9.2, 3, 0]. Answer: creates a list ⩥ mylist[0]. Answer: accesses first element from a list ⩥ mylist[-1]. Answer: accesses last element from a list ⩥ mylist[1:3]. Answer: slices list including second and third element ⩥ mylist[:3]. Answer: slices list beginning with first element and including through the third element. Index position 3 is not included in selection. ⩥ mylist[3:]. Answer: slices list beginning with fourth element and include remainder of the list ⩥ 9.2 in myNumbers. Answer: looks for a match and returns Boolean value
⩥ join(). Answer: joins values from a list using a defined separator ⩥ set(). Answer: creates a set, or a list that contains unique items ⩥ add(). Answer: adds value to set ⩥ discard(). Answer: removes value from set, if found ⩥ for city in cities:. Answer: iterates over items within a list ⩥ range(). Answer: defines a range of numbers ⩥ while temp >= 32:. Answer: iterates a set of commands as long as the condition remains true, stopping when the condition becomes false ⩥ break. Answer: loop command that stops iteration prematurely ⩥ studentGrades = { 'Orfu': 83, 'Bismark': 98, 'Igor': 72}. Answer: entries are added in key/value pairs ⩥ if 'key' in dictionary:. Answer: verifies if key exists in dictionary
⩥ get(). Answer: looks up value by key ⩥ myPhone = (877, 435, 7948). Answer: creates a tuple ⩥ open('/my_path/my_file.txt','r'). Answer: opens a file object for reading ⩥ open('/my_path/my_file.txt','w'). Answer: opens a file object for writing ⩥ read(). Answer: reads data from open file ⩥ close(). Answer: closes open file ⩥ write(). Answer: writes to open file ⩥ with open('/my_path/my_file.txt','r') as f:. Answer: opens a file, performs operations and automatically closes file ⩥ import math. Answer: imports math module ⩥ from collections import defaultdict. Answer: imports individual function from a module