Back to marketplace

CodeAcademy Python

No description yet. This curated deck is ready for daily study.

Total cards: 13•Content version: v4•Public deck•Updated: 8/1/2026

Card preview (13)

#1
Front (Question)

How do you define a function in python?

Back (Answer)

def your_function_name() the values that go inside can return a value so when the function is called, a value is returned.

#2
Front (Question)

How do you ensure that the program gives you output with decimal places when dividing an integer

Back (Answer)

you have to add the decimal place to the integer you are dividing. e.g. 15 -> 15.0

#3
Front (Question)

How do you write strings with apostrophes?

Back (Answer)

Use \ before the apostrophe

#4
Front (Question)

If you wanted to output the character n in Python, how would you do that?

Back (Answer)

Since counting starts at 0, n would be the 5th character, and thus you would write Python[5]

#5
Front (Question)

How do you find the length of a string? And how would you print it ?

Back (Answer)

print len(parrot) the input into len can be variable or a string

#6
Front (Question)

How do you turn a string into all lowercase?

Back (Answer)

add .lower() behind the string e.g. parrot = “Norwegian Blue”.lower()

#7
Front (Question)

Why is dot notation limited to upper() and lower()?

Back (Answer)

because they can only be applied to strings upper and lower are only used for strings

#8
Front (Question)

How do you do string substitution?

Back (Answer)

%s for where you want to substitute in the string and % before the set of variables you want to substitute in.

#9
Front (Question)

How would you go about outputting date and time

Back (Answer)

first you need to import the date and time you do that using from datetime import datetime Now you can define datetime as a variable for easier use. now = datetime**.now() datetime needs to be followed by .now() Next, you need to substitute the data in a string print ‘%s/%s/%s %s:%s:%s‘ % (now.month, now.day, now.year, now.hour, now.minute, now.second) %s is where you substitute in, % precedes what you want to substitute in.

#10
Front (Question)

What is the not equal sign?

Back (Answer)

!=

#11
Front (Question)

What does the boolean operator not do ?

Back (Answer)

The boolean operator not returns True for false statements and False for true statements. For example: not False will evaluate to True, while not 41 > 40 will return False.

#12
Front (Question)

what is the order of operation for boolean operators?

Back (Answer)

Boolean operators aren’t just evaluated from left to right. Just like with arithmetic operators, there’s an order of operations for boolean operators: • not is evaluated first; • and is evaluated next; • or is evaluated last.

#13
Front (Question)

what is the outcome of this boolean? True or not False and False

Back (Answer)

True True or not False and False. not gets evaluated first, so we have True or True and False. and goes next, so we get True or False. As we’ve seen, True or False is True,