Shared Flashcard Set

Details

Comp101
first test
37
Computer Science
Undergraduate 4
02/28/2012

Additional Computer Science Flashcards

 


 

Cards

Term
find 7/2 in decimal form
Definition
7.0/2
Term
find remainder of 7/2
Definition
7%2
Term
find 2^4
Definition
2**4
Term
find square root of 34
Definition
import math
math.sqrt(34)
Term
convert 5.45 to 5
Definition
int(5.45)
Term
convert 5 to 5.0
Definition
float(5)
Term
make 6/4 equal 1.5 without writing 6.0 or 4.0
Definition
float(6)/4
Term
assign two variables at the same time
Definition
x,y = 1,2
(x=1
y=2)
Term
find the third letter in string = "Chris"
Definition
string[2]
Term
find out number of char. in string = "Chris"
Definition
len(string)
Term
return "ris" from string = "Chris"
Definition
string[2:] or string [2:5]
Term
return "Chr" from string = "Chris"
Definition
string[:3]
Term
print characters of string in a list
Definition
for achar in string
print achar
Term
center a string in a certain amount of spaces
Definition
string.center(#)
Term
return the number of occurences of certain item in string
Definition
string.count(item)
Term
return string in all uppercase
Definition
string.upper()
Term
return string in all lowercase
Definition
string.lower()
Term
returns the index of first occurrence of item in string
Definition
string.find(item)
Term
splits string at certain character
Definition
string.split(char)
Term
split sentence string between words
Definition
string.split()
Term
split sentence string between words making a list
Definition
string.split()
Term
adding to a list
Definition
[item1, item2] + my list + [item3 + item4 + item5]
Term
convert string "Chris" to "ChrisChrisChris"
Definition
string*3
Term
convert list [2, 4, 5] to list [2, 4, 5, 2, 4, 5]
Definition
list*2
Term
find third item of list
Definition
list[2]
Term
find length of list
Definition
len(list)
Term
from list [2, 4, 5, 7, 9, 10] return [5, 7, 9]
Definition
list[2:5]
Term
add item to end of list
Definition
list.append(item)
Term
put new item in n.th spot in list
Definition
list.insert(n,item)
Term
removes and returns last item of list
Definition
list.pop()
Term
removes and returns n.th item from list
Definition
list.pop(n)
Term
sort list
Definition
list.sort()
Term
put list in backwords order
Definition
list.reverse()
Term
remove item in n.th position
Definition
del list[n]
Term
return index of first occurence of item
Definition
list.index(item)
Term
returns the number of occurrences of an item in a list
Definition
list.count(item)
Term
remove first occurrence of item from list
Definition
list.remove(item)
Supporting users have an ad free experience!