Partial preview of the text
Download WGU C859 Python Syntax latest updated v and more Exams Biology in PDF only on Docsity!
C859 Python Syntax latest updated version with 100% correct answers 2026-2027 var1, var2, var3 = 1, 2,3 | multiple variable assignment 12 | integer 1.2 | float ‘twelve’ | string “twelve” | string True or False Boolean value determines type of an object type() (integer, boolean, etc) int() : converts to integer object float() | converts to float object str() | converts to string object print() displays a message addition (integer) or * | concatenation (string) - | subtraction la | power of % | modulus, remainder / | division, always results in float H | division, always results in integer = | assignment operator += | reassignment operator, adds -= | reassignment operator, subtracts *= | reassignment operator, multiples /= | reassignment operator, divides < | less than > | greater than <= | less than or equal to >= | greater than or equal to == | equal to l= | not equal to len() | returns length myNumbers = [1, 4.8, 7, 9.2, 3, 0] creates a list mylist[0] accesses first element from a list mylist[-1] accesses last element from a list . slices list including second and mylist[1:3 . ylist{1 3] third element slices list beginning with first . element and including through mylist[:3] . g 9 the third element. Index position 3 is not included in selection. slices list beginning with fourth mylist[3:] element and include remainder of the list 9.2 in myNumbers looks for a match and returns Boolean value 9.2 not in myNumbers ensures a match does not exist in list len() counts items in list max() returns greatest element of list min() returns smallest element of list returns copy of list ordered sorted() PY smallest to largest sorted(listname, reverse=True) returns copy of list ordered largest to smallest sum() returns total sum of list values append() ! adds new value to end of list pop() removes last item from a list pop(1) ! removes second item from a list _ joins values from a list using a join() H . : defined separator set) creates a set, or a list that contains ! unique items add() adds value to set discard() : removes value from set, if found for city in cities: | iterates over items within a list range() ‘ defines a range of numbers while temp >= 32: iterates a set of commands as ! long as the condition remains true, stopping when the condition : becomes false break loop command that stops ! iteration prematurely studentGrades = { ‘Orfu': 83, ‘Bismark’: 98, ‘Igor’: 72} entries are added in key/value pairs if 'key' in dictionary: verifies if key exists in dictionary