Understand how to output text strings: Difference between revisions

From Computer Science Wiki
No edit summary
No edit summary
Line 12: Line 12:
print("from Warsaw")
print("from Warsaw")


# This is a handy to print many characters X number of times. I like to use this to visually  
# This is a handy to print many characters X number of times. I like to use this to visually separate output.  
# seperate output.  
print("=" * 25)
print("=" * 25)



Revision as of 08:33, 19 August 2021

Python programming language[1]

This page is meant to be used in conjunction with our excellent resource for learning python

For this topic we are learning how to output text string to the screen. You can also output text strings to a file (but that is a different lesson).

You will also learn how to comment your code.

# a normal hello world print statement in python:
print("hello world")
print("from Warsaw")

# This is a handy to print many characters X number of times. I like to use this to visually separate output. 
print("=" * 25)

# we will now look at the end keyword argument:
print("hello world", end='')
print("from Warsaw")
print("=" * 25)

# let's try a different end keyword argument:
print("hello world", end=' -- foo --')
print("from Warsaw")
print("=" * 25)

# we will now look at the sep keyword argument (what should we output between strings)
print("Hello","world", sep='..')
print("from","Warsaw", sep='--')


If you are still stuck, or you have other questions, you may want to ask a question on our discussion board.

References[edit]