import sys
print(sys.version) # Check Python version.
import math
math
math.sqrt(2)
7 * math.pi
print(7,8,9,sep='--') # Print in Python 3 is a function. sep is a keyword argument.
print('sandstone') # Here print is the function name, and 'sandstone' is the function's argument.
float(77) # float converts integers and strings to floating-point numbers.
int(70.98635) # int converts floating point values to integers by chopping off the fraction part.
int('17')
str(37) # str converts its argument to a string.
def print_rocks():
print("I'm a sandstone.")
print(print_rocks)
type(print_rocks)
print_rocks() # call print_rocks
def repeat_rocks():
print_rocks()
print_rocks()
repeat_rocks()
def print_twice(basalt):
print(basalt)
print(basalt)
print_twice('breccia')
igneous = 'granite, basalt, and etc.' # igneous is a variable, as an argument.
print_twice(igneous)
def fibonacci(N):
L = [0]
a, b = 0, 1
while len(L) < N:
a, b = b, a + b
L.append(a)
return L
fibonacci(10)