Changes

Jump to: navigation, search

OPS435 Python Lab 4

87 bytes added, 12:46, 20 June 2017
PART 1 - Strings and Substrings
== PART 1 - Strings and Substrings ==
:This first part will explain basic concepts of using strings, printing strings, and manipulating sub-strings. 
'''Perform the Following Steps:'''
:#Launch the ipython3 shell<source>
course_code = 'OPS435'
course_number = 435
</source>:#Strings can contain any characters inside them, whether they are letters, numbers, or symbols. In our ipython3 shell the values inside each string variable can be seen just by typing the string variable name. However, when writing python scripts, these string variables should be placed inside '''print() ''' functions in order to display on the screen. <br><br> Strings can also be concatenated(combined together) by using the '''+''' sign, just make sure string are only concatenating other strings(no lists, no numbers, no dictionaries, etc)<br><br>:#To demonstrate, issue the following:<source>
course_name
course_code
print(str(course_number))
print(course_name + ' ' + course_code + ' ' + str(course_number))
</source>:#Strings can also used use special syntax for string repitition repetition by multiplying the string by a number. This will repeat that string that many times. Repitition Repetition with '''*''' is useful whenever a string needs to be repeated more than once<br><br>:#Issue the following:<source>
print(course_name + '-' + course_code)
print(course_name + '-'*5 + course_code)
13,420
edits

Navigation menu