''' dataset is organized list of lists get text or get line closing_delimeter[ index_of_what_we want : where_to_start_searching_after_the_first_delimeter] import url #got to be in same folder as test programs use get_text( link ) to access web file ''' #import url reply = input( 'Enter link: ' ) link = reply.strip() #text = url.get_text( link ) #text now contains the appropriately formatted content of link ################## reply = input( 'Enter integers: ' ) #nbrs = int( reply ) #cannot work b/c int() can only take in one number argument and reply has multiple #'s strings = reply.split() #split the reply on the empty spaces between the input numbers --> this is a list!! #have to convert each of these string numbers one at a time #if get sum, initialize accumulator total_absolute_values = 0 for s in strings: #convert each number in strings list into an integer number = int( s ) #get absolute value of that number abs_number = abs( number ) #update total_absolute_values #accumulator (updated) = accumulator (old) + value_calculated total_absolute_values = total_absolute_values + abs_number #print out final result of loop print( total_absolute_values ) ################### #Why are strings immutable? # cannot change content of string # functions return a new string that has been modified from original #list is mutable = object can change #list[0] = 5 #has just changed the first element of list to 5 ################### #length of strings counts literal letters, spaces within single quotes, punctuations #strip() = gets rid of whitespaces in beginning and end #replace() = gets rid of all occurences of spaces in the string ################### x = [ 3, 1, '4', True ] x.append( '20' ) #adds '20' to end of list x print( x ) x = x.append( 11 ) print( x ) #when appending to a list, do not assign list = list.append(...)! ################### #when sorting strings, if string contains letters, sort by alphabetical order #when strings contain #'s, lexicographical order #look at characters one by one #so, 'A141' < 'A3' because 1 < 3 #so, max( v ) = 'A59' ################### #Python stores decimal in limited bits (64) --> most digits ~~15-16 digits ################### print() #print empty line in console reply = input( 'Enter four strings: ' ) strings = reply.split() #list of inputs sorted_strings = sorted( strings ) #sorted list of strings #no accumulator because you don't have to build anything here for s in sorted_strings: print( s ) #just printing vertically each element in the sorted_strings list #make sure your output matches up exactly with sample run!!! #################### #to "remove" a character from a string # str.replace( old_value, '' ) #removes value you want to replace and # replace with empty string aka nothing aka '' aka no space