some characters
print
functionprint
functionprint()
sends characters (strings) to the standard outputString concatenation:
In your groups, try the following operations:
"abc" * 4
+
and ,
. What is the difference?They sang AaAaAaAaAaAaAaAaAaAa
print
statementsprint
statementsprint
function sends the output cursor to the next line after printingAre You In College?
What other characters can you use for values for the end
parameter?
Write a simple program that prints the following output to the python console:
He said, "What's up?" Joe's friend didn't reply.
Submit your solution to the previous problem to gradescope
Name your file first.py
Also, like for the programming problems due next week, we will set up our code to be inside a main function (DEMO)
Remember that the print()
function prints a line break (\n
character) by default, you can change the default by specifying the parameter end
to be an empty string
Variable assignment does not produce any output to the console. Run the following code:
How would we print these variables?
Here’s a statement that invokes the print
function with the expression 3 + 4
as an argument.
"hello"
or 'hello'
3
3.14
True
or False
Use the function type()
with each literal type.
Try the following operators with the different types in python:
+ - * / // % **
Variable assignments are not like math — they can appear in equations that make no mathematical sense.
x = x + 2
means “take the current value of x, add it with 2, and assign the resulting value (7) to x as its new value.”
You have 10 minutes to complete the quiz.
Your solution needs to print the exact characters shown in your quiz (there are different versions of the quiz) – changes to the characters (for example, not printing the quotes or apostrophe) will be considered as an incorrect solution (zero grade awarded).
Comments
Computer program can include comments, which are simply text that is meant to be read, but not executed.
The purpose of comments is to “document” the program so that subsequent readers can more easily understand it, or learn things about it (e.g., its original author).