Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
32 Cards in this Set
- Front
- Back
len( )
|
give the length of a list.
|
|
max( )
|
Gives the maximum value of a list.
|
|
abs( )
|
give the absolute value of a number.
|
|
pow(x, y[z,])
|
It gives x**y with two arguments, the optional third arg is equivalent to (x**y)%z.
|
|
dir(__builtins__)
|
Outputs the list of all builtin functions.
|
|
help(func)
|
Shows the help file of the function 'func'.
|
|
del gases[0]
|
Delete the first element of the list gases.
|
|
gases.append('Ne')
|
The method append will append 'Ne' as the last element of the list gases.
|
|
What are methods in Python?
|
A method is a subroutine(or procedure) associated with a class.
file.method, a method is a function that 'belongs' to and operates on a specific chunk of data |
|
gases.count('He')
|
Shows how many times the entry 'He' is on the list gases.
|
|
gases.index('Ar')
|
gives the index of the entry in the list gases.
|
|
print(x)
|
It will print the variable x and add one line.b
|
|
What are the rules for legal names in Python?
|
1. Names must start with a letter or _.
2. Names must contain only letters, digits, and _. |
|
What is the name convention in Python
|
It is the pothole. My_Variable_long.
|
|
What is the keyword to define a function in Python?
|
It is 'def'. Example:
def my.function(x, y, z) print(x, y, z) |
|
What is comment keyword?
|
it is #
|
|
What the keyword 'return' means?
|
a keyword indicating the result of a function. Return statement is: return expression. Used in function definitions.
|
|
What is a parameter?
|
It is a variable that appears between the parentheses of a function definition. Parameters get their values to expressions in a function call.
|
|
What is a string literal?
|
It is a sequence of characters.
|
|
How to import all the functions of a module in python 2.x ?
|
from math import * # use * to import
|
|
How to prefix the module being imported with a short name ?
|
import matplotlib.pyplot as plt
|
|
How to import the pi number?
|
from math import pi
|
|
How to generate n equally spaced coordinates from a start point to a stop ?
|
linspace(start, stop, n) # from numpy import linspace
|
|
How many elements is the output of: print(list[0:3])?
|
The first three elements, but not the fourth(index 3), is not included.
|
|
What the _ means when making operations ?
|
it's a variable with the last value returned in the prompt
|
|
What is the format of a dictionary in py ?
|
var = { key1 : name1, key2 : name2}
|
|
How assignments can be done on more than one variable "simultaneously" ?
|
a, b = 3, 4 #on the same line.
|
|
Which method remove white space in right end of a string ? |
name_of_var.rstrip() |
|
Which method remove white space in left end of a string ? |
name_of_var.lstrip() |
|
How to have basic functions for plotting, like plt.plot(),plt,hist(),plt.show() and the like ? |
import matplotlib.pyplot as plt |
|
How to make a log scale to a graph ? |
plt.xscale('log') |
|
How to make a scatter plot ? |
plt.scatter(x,y) |