CodeAcademy Python

Ace your homework & exams now with Quizwiz!

def spam(): eggs = 12 return eggs print spam()

Properly indent the code with four spaces before eggs on line 2 and another four before return on line 3.

Set fifth_letter equal to the fifth letter of the string "MONTY"

fifth_letter = "MONTY"[4]

Assign meal to the value of itself + itself * tax

meal += meal * tax Note: syntactic sugars exist in python

Set the variable spam equal to 5

spam = 5

For multi-line comments, you can include the whole block in a set of triple quotation marks:

"""Sipping from your cup 'til it runneth over, Holy Grail. """

Let's take a closer look at why you use len(string) and str(object), but dot notation (such as "String".upper()) for the rest. Methods that use dot notation only work with strings

On the other hand, len() and str() can work on other data types.

A boolean is like a light switch. It can only have two values. Just like a light switch can only be on or off, a boolean can only be ______ or _____.

True, False

In Python, whitespace is used to structure code.

Whitespace is important, so you have to be careful with how you use it.


Related study sets

Courts and Criminal Procedures Final Exam

View Set

NCLEX- leadership and management

View Set

Accounting 285 Final Exam Tophat Questions

View Set

Chapt 15 Network Troubleshooting

View Set

Nursing Reading Guide - Chapter 19:

View Set

Lewis Chapter 45: Renal and Urological Problems

View Set

Managerial accounting chapter 6

View Set