4.6 Flashcards
“For” loop statement.
iterates over a list of items or a group of steps for each item in a list.
“For” Loop code for range.
for n in range (10):
print(n)
“For” loop for sequence(fruits).
fruits=(“Apples”,”Oranges”,”Banana”)
for n in fruits:
print(n)
“While” loop statement
repeats a step or group of steps while a given condition is true
“while” loop code
n = 10 while n > 0: print(n) n = n - 1 print ("i like python.")
python built-in function that returns absolute value of a number.
abs()
python built-in function that returns string containing printable representation.
ascii()
python built-in function that converts integer to binary string
bin()
python built-in function that returns a character (a string) from an integer.
chr()
python built-in function that returns the number of items in an object or the number of characters in a string.
len()
python built-in function returns x to the power of y
pow()
python built-in function that prints the given object
print()
python built-in function that returns sequence of integers between start and stop
range()
python built-in function that rounds a floating point number to n places
round()
python built-in function that adds items of an iterable
sum()