Python Programming Functions
10 Questions
0 Views

Python Programming Functions

Created by
@LawfulOsmium9639

Questions and Answers

What command gives a quick list of defined symbols in Python?

  • snapshot
  • view
  • dir (correct)
  • help
  • What aspect of a piece of code affects its meaning in Python?

  • whitespace indentation (correct)
  • space between lines
  • both A and B
  • none of the above
  • How are logical connectors spelled out in Python?

  • Letters
  • Integers
  • Symbols (correct)
  • All of the above
  • What is the value of an empty string in Python boolean operations?

    <p>False</p> Signup and view all the answers

    What prefix is used to create a raw string literal in Python?

    <p>r</p> Signup and view all the answers

    What is the length of the string r'x\nx'?

    <p>3</p> Signup and view all the answers

    What is the return value of list.append() in Python?

    <p>None</p> Signup and view all the answers

    What does REPL stand for in Python?

    <p>Read-Evaluate-Print-Loop</p> Signup and view all the answers

    What is the term for testing individual units of source code?

    <p>Unit Testing</p> Signup and view all the answers

    What is the smallest testable part of an application?

    <p>Unit</p> Signup and view all the answers

    Study Notes

    Python Functions

    • round(45.8) returns the rounded value of 45.8
    • round(6352.898,2,5) is not a valid syntax for the round function
    • round() without arguments is not a valid function call
    • round(7463.123,2,1) is not a valid syntax for the round function

    Python Data Types

    • The id function returns an integer value that is unique for each object
    • In Python, you do not specify types, it is directly interpreted by the compiler
    • The // operator is used for integer division in Python 3.0
    • The int(..) function is used to type cast a value to an integer

    Python Operations

    • The * operator is used for string repetition, not mathematical multiplication
    • The + operator is used for string concatenation, not mathematical addition
    • The / operator is used for float division, not integer division

    Python Syntax

    • Indentation is required for Python codes to be executed correctly
    • You cannot perform mathematical operations on strings
    • The def keyword is used to define a function

    Python Data Structures

    • A list stores values of any data type, including strings and integers
    • A dictionary stores values in terms of keys and values
    • An array is not a built-in data structure in Python

    Python String Operations

    • The print function can be used to display strings with newline characters (\n)
    • Strings can be concatenated using the + operator
    • Strings can be repeated using the * operator

    Python Class and Objects

    • An object represents an entity in the real world with its identity and behavior
    • A class defines an object
    • A constructor is used to create an object with assigned values to its members

    Python Miscellaneous

    • The trunc function returns an integer value
    • The help function can be used to get details of a function or module
    • The dir function gives a quick list of defined symbols in Python
    • Logical connectors are spelled out with letters
    • Whitespace indentation affects the meaning of Python code
    • Empty string is counted as False in Python boolean operations
    • A "raw" string literal is prefixed by an r and passes all characters through without special treatment of backslashes
    • REPL stands for Read-Evaluate-Print-Loop
    • Unit testing is a method by which individual units of source code are tested to determine if they are fit for use
    • A unit is the smallest testable part of an application

    Studying That Suits You

    Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

    Quiz Team

    Description

    Multiple choice questions about Python functions including round and id functions.

    Use Quizgecko on...
    Browser
    Browser