• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/57

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

57 Cards in this Set

  • Front
  • Back

Line of code that will output: Hello, World!

print ('Hello, World')

Use _________ to determine which mathematical operations are performed first

Parenthesis

Using a / for division produces a _______.

Float

A float is a number with a _______.

Decimal

Computers can't store ______ completely accurately, which can lead to bugs.

Floats

What are 3 ways a float can be produced?

Division


Running an operation on two floats


Running an operation on a float and an integer

How do you perform exponentiation?

Two asterisks - (Base**Exponent)

Create a sting by putting _______ between ' or " marks.

Text

How do you include a character that can't be directly included in a string? Ex: a double quote

Use a backslash

\n represents a ___ ______.

New Line

___ is automatically put in the output, where you press Enter. IF you put your string inside of _ sets of quotes.

\n , 3

A program takes _____ to produce ______

Input, output

You can use the ____ function to produce output.

Print

How do you prompt the user for input?

raw_input('prompt')

User input is automatically returned as a ______. (With the contents automatically escaped.)

String

As with integers and floats, _______ in Python can be added, using a process called __________.

strings, concatenation

To add a string that contains a number to an integer you must first __________________.

Convert the string to an integer

You can multiply a string by an integer. (T or F)

True

You can multiply a string by a float. (T or F)

False

what is the output of this code:




print(3 * '7')

777

How do you convert the string "83" into the integer 83?

int("83")

How do you convert the integer 7 into the float 7.0?

float(7)

How do you convert the integer 83 into the string '83'

str(83)

What is the output of this code and why?




int('6'+'3')

63 , because the operation inside the parenthesis is done first and while '6' and '3' are inside the parenthesis they are strings so their sum is '63', which is THEN converted into the integer 63

How do you convert user input (which is automatically a string) into an integer?

int(raw_input("prompt:"))

A _______ allows you to store a value by assigning it to a name.

Variable

To assign a variable use an ____ sign

=

Variables can be reassigned as many times as you want. (T or F)

True

You can assign a variable to an integer and then later assign that same variable to a string. (T or F)

True

The only characters allowed in a variable name are:

Letters, Numbers, Underscores

is 13_Hab an acceptable variable name?

No, variable names cannot begin with numbers

Variable names are _____ sensitive.

case

How do you delete a variable?

del variable name

You can also take the value of the variable from user input. (T or F)

True

In-place operators allow you to write code like


'x = x + 3' more concisely, as:

x + = 3

What is the output of this code?


>>> x = 3


>>> num = 17


>>> print(num % x)

2 (remainder)

What are the two Boolean values in python?

True and False

What is the Boolean equal operator in python?

==

What is this Boolean operator? !=

Not equal to

Is this a true or false statement?




1 != 1

False

Is this a true or false statement?




2 != t

True

What are the Boolean operators for greater than / less than?

> <

What are these Boolean operators?




<= >=

Greater than / less than (or equal to)

(T or F)




The > < operators can be used to compare two strings lexicographically

True

You can use an __ ________ to run code if a certain condition holds

if statement

Python uses ______ to delimit blocks of code

Indentation

The end of an if statement should contain a _.

:

If statements can be _______ to perform more complex checks. This is one way to see if ______________ are met.

nested, multiple conditions

What is the output of this code?


num = 7


if num > 3:


print("3")


if num < 5:


print("5")


if num ==7:


print("7")

3, because since 7 is not less than 5 the next nested statement is never reached

An else statement follows __________.

An if statement

An else statement contains code that is called when _____________________.

The if statement evaluates to false

(T or F)




Else statements must be followed by a :

True

The _____ statement is a shortcut to chaining if else statements.

elif

elif statements can have a final ________.

Else statement

The and operator takes two arguments and evaluates as true if _________.

both arguments are true

The or operator takes two arguments and evaluates to true if ______________.

Either (or both) arguments is/are true.

The operator not only takes one argument and _________ it.

Inverts