Ijaz
Engineering 102 Exams 1 & 2 - TAMU -
Ijaz
Turn mystr = "string1 string2 string3" into a list - ANSWER mystr = mystr.split(" ")
Turn mystr = "1234" into a list - ANSWER mystr = list(mystr)
bool("any string") - ANSWER True
format the float var to have x decimal places and print it - ANSWER print('{:.xf}'.format(var))
loop the dictionary my_dict - ANSWER for key, value in my_dict.items():
How to input two variable at a time (x and y) - ANSWER x, y = input("...").split()
loop through the values in my_dict - ANSWER for value in my_dict.values():
loop through the keys in my_dict - ANSWER for key in my_dict.keys():
string.ljust(x) will... - ANSWER add x-len(string) amount of spaces to the right the string
string.rjust(x) will... - ANSWER add x-len(string) amount of spaces to the left the string
\b - ANSWER will delete the last character of the string
\t - ANSWER will print it tabbed
, Engineering 102 Exams 1 & 2 - TAMU -
Ijaz
use the find function find the index of x in mystr - ANSWER mystr.find(x)
import math module - ANSWER from math import *
import pi - ANSWER math.pi
define a function called myfun - ANSWER def myfun():
call a funtion called myfun - ANSWER myfun()
put ==, and, or, & not in order of operations - ANSWER ==, not, and, or
bool() - ANSWER False
bool(0) - ANSWER False
bool(1) - ANSWER True
2 things that will make the code stop running - ANSWER exit() and quit()
True or False: you can add lists like
newList = smallList1 + smallList2 - ANSWER True
adds something to the end of a list (list) - ANSWER list.append()
in a list, what will insert x to make it index i - ANSWER list.insert(i, x)