2nd quarter (COMP10) (PHINMA)

Cards (46)

  • What function is used to request user input in Python?
    input()
  • What does the input() function do with the entered data?
    It saves the data as a string.
  • What is the syntax for the input() function?
    message = input("This is where you type in your input request: ")
  • What function is used to print messages on a device's screen?
    print()
  • What format is the print message always in?
    String format.
  • What happens if the print message is in other objects?
    It is converted into a string before being printed.
  • What does the type() function do in Python?
    It returns the type of data stored in an object or variable.
  • What are f-strings in Python?
    Formatted string literals that embed expressions inside string literals.
  • How do you embed expressions in f-strings?
    Using curly braces {}.
  • What is the purpose of the int() function?
    To convert a number or string to an integer.
  • What does the str() function do?
    It converts a specified value into a string datatype.
  • What is the function of float() in Python?
    It converts values into floating point numbers.
  • What does the bool() function return?
    A boolean value.
  • What is typecasting?
    The process of converting a variable from one data type to another.
  • If you have a variable height = 5.7, what would height = int(height) return?
    5
  • What does print(type(height)) return after height = int(height)?
    <class 'int'></class>
  • What does the input() function prompt the user to do?
    Enter data.
  • What does the input() function return?
    The entered data as a string.
  • How would you greet a user after getting their name using input()?
    print(f"Hello {name}!")
  • How do you calculate the area of a rectangle in Python?
    area = length * width
  • What is the output of print(f"The area is: {area} square centimeters") if area = 28.0?
    The area is: 28.0 square centimeters
  • In the Shopping Cart Program, how do you calculate the total cost?
    total = price * quantity
  • What is the output of print(f"You have bought {quantity} pieces of {item}/s.") if quantity = 5 and item = "Icewater"?
    You have bought 5 pieces of Icewater/s.
  • What is the initial value of friends in the sample arithmetic operators?
    0
  • What does friends += 2 do to the variable friends?
    It increases the value of friends by 2.
  • What are the augmented assignment operators in Python?
    • += for addition
    • -= for subtraction
    • *= for multiplication
    • /= for division
    • **= for exponentiation
    • %= for remainder
  • What does the round() function do?
    It rounds a floating-point number to the nearest integer.
  • What is the output of print(result) if result = round(3.14)?
    3
  • What does the abs() function return?
    The absolute value of a number.
  • What is the output of print(result) if result = abs(-4)?
    4
  • What does the pow() function do?
    It raises a number to the power of another number.
  • What is the output of print(result) if result = pow(4, 2)?
    16
  • What does the max() function return?
    The maximum value among the given arguments.
  • What is the output of print(result) if result = max(3.14, 4, 5)?
    5
  • What does the min() function return?
    The minimum value among the given arguments.
  • What is the output of print(result) if result = min(3.14, 4, 5)?
    1.14
  • What is the output of print(math.pi) after importing the math module?
    1.141592653589793
  • What is the value of the mathematical constant ee in Python's math module?
    1.718281828459045
  • What does the function math.ceil(x)math.ceil(x) do in Python?

    It returns the smallest integer greater than or equal to xx
  • If x=x =9.4 9.4, what is the result of math.ceil(x)math.ceil(x)?

    10