Python Study

The flashcards below were created by user caldreaming on FreezingBlue Flashcards.

  1. T/F   Python is an interpreted programming language.

    A) True
    B) False
    A) True
  2. How can you tell if you are in the interactive shell in Python Idle or the file editor?
    The interactive shell will have the command prompt '>>>' for you to enter code whereas the file editor is just a blank file screen.
  3. What are the elements of expressions in Python?
    Expression = Values + Operators

    • Ex. 2 + 2              2 + 2
    •   Value                   Operator
  4. Expressions always ______________.
    Evaluate and reduce to a single value.
  5. If a Python instructions evaluates to a single value we call them;
  6. If a Python expression does NOT evaluate to a single value then we call them;
  7. The current instruction being processed in Python is called;
    The Execution
  8. Values passed to functions are called;
  9. In Python the function to output text to the screen is;

    Example: print('Hello World')
  10. In Python the function to get information from the user is;

    Example:  myName = input()
  11. What is the syntax for adding a comment in a Python program?
    # text

    The # sign indicates everything to follow on the same line is a comment

    Example:  # This is a comment
  12. What function in Python is used to get the length of a variable?

    Example:  len(myName) where 'myName' is a variable.
  13. What is the function to turn a string value into an integer for doing math?

    • Example:  int(myName)
    • Returns: 3
    • If the value of myName is 'Bob' then it is interpreted as 3 since that is the length of that variable.

    • Example:  int('1243')
    • Returns: 1243
  14. In Python what command can you use to run on an integer variable to turn it into a string?

    • Example:  str(26)
    • Returns:  '26'
  15. In Python which function can you use to get a floating point version of an integer value?

    • Example:  float(1)
    • Returns: 1.0
  16. How do you set a Boolean value to a variable in Python?
    • Example: isDay = True
    • Example: isNoon = False

    The key is to remember to use a capital letter for either True or False.
  17. Comparison operators within Python evaluate to;
    True or False
  18. The comparison operator in Python for "is not equal to" is written;

    • Example:  1 != 2
    • Returns:  True

    • Example: 1 != 1
    • Rerturns: False
  19. The comparison operator in Python for "equal to" is written;

    • Example:  5 == 5
    • Returns: True

    • Example: 7 == 3
    • Returns: False
  20. What can be said about bugs or bad inputs within Python code?
    A bug or bad input will never cause a segmentation fault but instead when the interpreter discovers an error it raises an exception. 

    When the program doesn't catch the exception, the interpreter prints a stack trace.
  21. What is a segmentation fault?
    A segmentation fault (aka segfault) is a common condition that causes programs to crash; they are often associated with a file named core . Segfaults are caused by a program trying to read or write an illegal memory location.
  22. What is an exception?
    An interruption in normal processing, especially as caused by an error condition.
  23. What are the 3 Boolean operators in Python?
    • 1) And
    • 2) Or
    • 3) Not
  24. In Python, blocks of code are sometimes called;
Card Set:
Python Study
2016-01-22 22:18:05
python programming development software server side scripting

Python study materials
Show Answers: