Tags:
create new tag
view all tags

Python Activity 1: Introduction to Python

Partners: ____________

Learning Objectives

Students will be able to:
Content:

  • Explain how to display data in Python
  • Explain how to create a comment in Python
  • Determine the difference between a string literal and a number Process:
  • Create print statements in Python
  • Create Python code that displays results to calculated addition facts
  • Discuss problems and programs with all group members
Prior Knowledge
Be able to input and execute Python code using the Python IDE
Critical Thinking Questions:

Screen_Shot_2018-07-05_at_12.57.45_PM.png
1.Enter the Python program shown above. What does it do?

FYI:A "string literal" is a sequence of characters surrounded by double quotation marks (" ").
2.Type and execute following code. What output is produced? Indicate if there is a problem.
  • a. print(“Hello, my name is Pat!”)
  • b. print(Hello, my name is Pat)
  • c. print(“Hello.\nMy name is Pat”)
3. What caused the different output format for samples “a” and “c” in question 2?

4. What do you think the following Python statements output?Enter the statements in the interactive mode of the Python interpreter to verify your answers.

  • a. print(2+5)
  • b. print(2*5)
  • c. print(“2+5”)
  • d. print(“Age:”,20)
5. Examine the output for each statement in question 4.
  • a. What is the difference in the output for the statements in “a” and “c” of question 4?
  • b. What caused the difference?
  • c. Which statements contain a string literal?
  • d. What does the comma (,) do in the print statement in part “d” of question 4? How does it affect the spacing of the output?
6. Examine the following code and its output. What do the first three lines of the program do?

Screen_Shot_2018-07-05_at_1.02.51_PM.png

Output:

Screen_Shot_2018-07-05_at_1.03.16_PM.png

7. What would happen if you placed a “#” in front of the code:

print("Hello, Pat!") 

in the previous program?

Application Questions: Use the Python program mode to design and check your work

1. Create a Python program containing three statements to print the following output. Write the statements below.

Screen_Shot_2018-07-05_at_1.10.19_PM.png

2.Create a Python program containing two statements that prints the output below. Have the program calculate the answers to the two arithmetic problems.

Screen_Shot_2018-07-05_at_1.11.32_PM.png

Topic attachments
I Attachment History Action Size Date Who Comment
PNGpng Screen_Shot_2018-07-05_at_1.02.51_PM.png r1 manage 40.5 K 2018-07-05 - 17:03 JimSkon  
PNGpng Screen_Shot_2018-07-05_at_1.03.16_PM.png r1 manage 6.0 K 2018-07-05 - 17:03 JimSkon  
PNGpng Screen_Shot_2018-07-05_at_1.10.19_PM.png r1 manage 17.3 K 2018-07-05 - 17:10 JimSkon  
PNGpng Screen_Shot_2018-07-05_at_1.11.32_PM.png r1 manage 10.3 K 2018-07-05 - 17:12 JimSkon  
PNGpng Screen_Shot_2018-07-05_at_12.57.45_PM.png r1 manage 22.4 K 2018-07-05 - 16:58 JimSkon  
Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r2 - 2018-07-05 - JimSkon
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback