CIS 109 Final Exam: Python Programming Fundamentals
30 Questions
1 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What is a key feature of Python that makes it more readable?

  • It uses fewer English keywords
  • It has more syntactical constructions
  • It is a low-level language
  • It uses English keywords frequently (correct)
  • What programming methods does Python support?

  • Only functional and structured programming
  • Only procedural programming
  • Functional and structured programming, as well as object-oriented programming (correct)
  • Only object-oriented programming
  • What is a benefit of Python's automatic garbage collection?

  • It is only available in other languages
  • It requires manual memory management
  • It frees the developer from worrying about memory management (correct)
  • It is slower than manual memory management
  • What environment variable tells the Python interpreter where to locate module files?

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

    What is the correct function to convert a string into a floating point number?

    <p>float()</p> Signup and view all the answers

    What environment variable is used in Windows to instruct Python to find the first case-insensitive match in an import statement?

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

    Which environment variable is used to specify an alternative module search path in Python?

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

    Is Python a case-sensitive language?

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

    What is the proper Python syntax to close a file?

    <p>close(fileObject)</p> Signup and view all the answers

    What is the output of print str if str = 'Hello World!'?

    <p>Hello World!</p> Signup and view all the answers

    What is the output of print str[2:5] if str = 'Hello World!'?

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

    What is the output of print str * 2 if str = 'Hello World!'?

    <p>Hello World!Hello World!</p> Signup and view all the answers

    What is the output of print list if list = [ 'abcd', 786 , 2.23, 'john', 70.2 ]?

    <p>[ 'abcd', 786 , 2.23, 'john', 70.2 ]</p> Signup and view all the answers

    What is the output of print list[1:3] if list = [ 'abcd', 786 , 2.23, 'john', 70.2 ]?

    <p>[786, 2.23]</p> Signup and view all the answers

    What is the output of print list[2:] if list = [ 'abcd', 786 , 2.23, 'john', 70.2 ]?

    <p>[2.23, 'john', 70.2]</p> Signup and view all the answers

    What is the Math Operator for Exponentiation in Ruby?

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

    What is the output of the statement? puts "#{3 + 2}" in Ruby?

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

    What is the correct syntax to interpret a line of code as a math operation in Ruby?

    <p>&quot;#{}&quot;</p> Signup and view all the answers

    In Linux, where is text read or written in emacs?

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

    In Ruby, which of the following will output the first item in an array?

    <p>puts(cool_array)</p> Signup and view all the answers

    What does EMACS stand for in Linux?

    <p>Editing Macros</p> Signup and view all the answers

    In Linux, which symbol is used to reference a variable?

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

    Which of the following is a way to concatenate strings in Ruby?

    <p>puts('test ' + 3)</p> Signup and view all the answers

    What does sudo stand for in Linux?

    <p>superuser do</p> Signup and view all the answers

    What is the correct way to create a constant with value 3 in Ruby?

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

    In Linux, what are wildcard characters known as?

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

    What is the term used for things that describe or characterize an object in Ruby?

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

    How does Ruby treat numbers and other primitive data types?

    <p>As objects</p> Signup and view all the answers

    In Linux, what is the purpose of a comment line?

    <p>To explain the purpose of a command or function</p> Signup and view all the answers

    What is the correct statement about Perl?

    <p>Perl stands for Practical Extraction and Report Language</p> Signup and view all the answers

    Study Notes

    Python Features and Functions

    • Python emphasizes readability through its clean, straightforward syntax, which reduces complexity.
    • Supports multiple programming paradigms, including procedural, object-oriented, and functional programming.
    • Automatic garbage collection simplifies memory management, as it periodically frees up memory by deleting unreferenced objects.
    • The PYTHONPATH environment variable directs the Python interpreter to locate module files.
    • The function float() is used to convert a string into a floating-point number in Python.
    • The PYTHONCASEOK environment variable allows Python to find the first case-insensitive match during imports.
    • The PYTHONPATH environment variable can also be set to specify alternative module search paths.

    String and List Operations in Python

    • Python is a case-sensitive language, meaning variable and function names are case-specific.
    • Files are closed using the file.close() method in Python syntax.
    • Output of print(str) when str = 'Hello World!' is Hello World!.
    • The output of print(str[2:5]) for str = 'Hello World!' is llo.
    • The output of print(str * 2) when str = 'Hello World!' is Hello World!Hello World!.
    • The output of print(list) when list = ['abcd', 786, 2.23, 'john', 70.2] is ['abcd', 786, 2.23, 'john', 70.2].
    • The output of print(list[1:3]) for the same list is [786, 2.23].
    • The output of print(list[2:]) results in [2.23, 'john', 70.2].

    Ruby Features and Functions

    • The exponentiation operator in Ruby is **.
    • The statement puts "#{3 + 2}" in Ruby outputs 5, because it evaluates the expression inside the string interpolation.
    • To interpret a line of code as a math operation in Ruby, the syntax uses standard arithmetic operators.
    • In Emacs on Linux, text is read or written in buffers.
    • To output the first item in an array in Ruby, one can use array.first or array[0].
    • EMACS stands for "Editor MACro System," a powerful text editor in Linux.
    • In Linux, the $ symbol is used to reference a variable.
    • Strings in Ruby can be concatenated using the + operator or the << (shovel) operator.

    Linux and General Concepts

    • sudo stands for "superuser do," allowing users to execute commands with elevated privileges.
    • A constant in Ruby can be created with CONSTANT_NAME = 3, where the constant name is typically uppercase.
    • Wildcard characters in Linux are known as "globbing".
    • Properties that describe or characterize an object in Ruby are referred to as attributes or methods.
    • Ruby treats numbers and other primitive data types as objects, endowing them with methods.
    • In Linux, comment lines are used to explain the code, making it easier to understand and maintain.
    • Perl is known for its text processing capabilities and supports procedural and object-oriented programming.

    Studying That Suits You

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

    Quiz Team

    Description

    Test your knowledge of Python programming basics with this CIS 109 final exam study guide. Explore the language's features, syntax, and programming methods. Review the correct answers to these multiple-choice questions and improve your understanding of Python.

    Use Quizgecko on...
    Browser
    Browser