Open main menu

CDOT Wiki β

Changes

OPS435 Python Lab 4

32 bytes added, 09:13, 21 June 2017
PART 1 - Strings and Substrings
print('abc'*2)
print(course_code*5)
</source>When using the '''print()''' function, you can display '''special characters'''. One such special character is the is the newline character (denoted by the symbol: '''\n'''). This allows you to separate content between new lines or empty lines.<br><br>
:#To demonstrate, issue the following:<source>
print('Line 1\nLine 2\nLine 3\n')
course_name.upper() # Returns a string in upper-case letters
course_name.swapcase() # Returns a string with upper-case and lower-case letters swapped
course_name.title() # Returns a string with upper-case first letter of each word lower on rest, lowercase for remaining textcourse_name.capitalize() # Returns a string with upper-case first letter in string lowere on restonly, lowercase for remaining text
</source>
:#These values can be saved inside new strings and reused for any new tasks<source>
13,420
edits