0% found this document useful (0 votes)
12 views2 pages

Python List

The document discusses Python lists, tuples, functions, return statements, if statements, and a max number calculator function. It provides examples of using pop, remove, clear, sort, reverse, and copy methods on lists as well as defining and calling functions that return values or print output.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views2 pages

Python List

The document discusses Python lists, tuples, functions, return statements, if statements, and a max number calculator function. It provides examples of using pop, remove, clear, sort, reverse, and copy methods on lists as well as defining and calling functions that return values or print output.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Python list

Use []

.pop = removes the last element at the list

.remove

.clear

.sort = sort elements alphabetically

.reverse

.copy

Tuples = cant change after making it

Use ()

Function

def say_hi(name):

print(“Hello ” + name)

write say_hi(“Mike”) . It will execute whats inside the function

Return Statement

def cube(num)

return num*num*num

result = cube(4)

print(result)

you can’t use a print() under a return statement

If Statements

not(is_tall)

else

elif

def max_num(num1, num2, num3):

if num1 >= num2 and num1 >= num3:

return num1
if num2 >= num1 and num2 >= num3:

return num2

else:

return num3

print(max_num(3, 4, 5))

Calculator

You might also like