Python Octal Numbers and Data Structures Quiz
30 Questions
0 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

Which Python syntax correctly represents an octal number?

  • 0o123 (correct)
  • 123o
  • 0x123
  • oct(123)
  • Which of the following is NOT a valid way to define an octal number in Python?

  • 25o (correct)
  • 0O34
  • oct(21)
  • 0o25
  • What is the decimal equivalent of the octal number 17?

  • 19
  • 17
  • 15 (correct)
  • 23
  • Given the octal number 12, what is its binary equivalent?

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

    Which function would you use to convert a decimal number to octal in Python?

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

    What is the primary characteristic of the data structure described?

    <p>It does not support indexing or slicing.</p> Signup and view all the answers

    How are items populated in this data structure?

    <p>By simply listing the items enclosed in curly braces.</p> Signup and view all the answers

    What happens to the items in this data structure related to uniqueness?

    <p>Only the first instance of each item is stored.</p> Signup and view all the answers

    How does this data structure treat its elements?

    <p>It hashes items to ensure uniqueness.</p> Signup and view all the answers

    When defining this data structure, which of the following is true?

    <p>It uses commas to separate items without colons.</p> Signup and view all the answers

    What does the statement d['Ali'] = 20 represent in the context of a dictionary?

    <p>It assigns the key 'Ali' a value of 20 in the dictionary.</p> Signup and view all the answers

    Which of the following statements is true regarding dictionary keys?

    <p>Dictionary keys must be unique within the same dictionary.</p> Signup and view all the answers

    What is the primary characteristic of an empty string in terms of memory usage?

    <p>It requires one byte for its termination character.</p> Signup and view all the answers

    If d is a dictionary, what will d.get('Ali') return if 'Ali' does not exist in the dictionary?

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

    How can you ensure that all keys in a dictionary are of the same data type?

    <p>This is not achievable as Python allows mixed types.</p> Signup and view all the answers

    What does MRO stand for in the context of class relations?

    <p>Method Resolution Order</p> Signup and view all the answers

    Which of the following concepts is related to inheritance in programming?

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

    In programming, what is a characteristic of multiple inheritance?

    <p>A class can inherit from multiple parent classes.</p> Signup and view all the answers

    Which of the following statements best describes the concept of composition?

    <p>It refers to the creation of new classes using existing classes.</p> Signup and view all the answers

    What is a potential issue that can arise from multiple inheritance?

    <p>Ambiguity in method resolution.</p> Signup and view all the answers

    What is the purpose of the append method in programming?

    <p>To add an item to the end of a list</p> Signup and view all the answers

    How can we generate multiples of 3 between 3 and 999 in Python using one line of code?

    <p>list(range(3, 999, 3))</p> Signup and view all the answers

    What is a significant property of the range function in Python?

    <p>It returns an iterable that generates numbers on demand</p> Signup and view all the answers

    Which of the following descriptions about the range function is incorrect?

    <p>It cannot generate negative numbers</p> Signup and view all the answers

    Which of the following statements is true regarding range creation?

    <p>The function can use a step to skip values</p> Signup and view all the answers

    What functionality does the 'in' operator provide in Python?

    <p>It determines if an element exists within a collection.</p> Signup and view all the answers

    Which of the following correctly describes the syntax for using the 'in' operator?

    <p>'element in collection'</p> Signup and view all the answers

    What would be the outcome of evaluating 'a in b' if a is 5 and b is a list containing [1, 2, 3]?

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

    Which of the following statements is true when using the 'in' operator with strings?

    <p>'substring in main_string' returns True if substring is found.</p> Signup and view all the answers

    How does the 'in' operator behave when used with dictionaries in Python?

    <p>It checks for the presence of keys.</p> Signup and view all the answers

    Study Notes

    Bash Commands

    • ls: Lists the contents of a directory.
    • ls -a: Lists all files and directories, including hidden ones.
    • ls -A: Lists all files and directories, excluding hidden ones and the current directory (.) and parent directory (..).
    • pwd: Prints the current working directory.
    • cd: Changes the current working directory.
    • cd <directory>: Changes to the specified directory.
    • cd ..: Changes to the parent directory.
    • cd ~: Changes to the home directory.
    • mkdir <directory>: Creates a new directory.
    • rmdir <directory>: Removes an empty directory.
    • rm <file>: Removes a file.
    • rm -r <directory>: Removes a directory and its contents recursively.
    • cp <source> <destination>: Copies a file or directory.
    • cp -r <source> <destination>: Copies a directory and its contents recursively.
    • mv <source> <destination>: Moves or renames a file or directory.
    • touch <file>: Creates an empty file.
    • wc -l <file>: Counts the number of lines in a file.
    • wc -w <file>: Counts the number of words in a file.
    • wc -c <file>: Counts the number of characters in a file.
    • head -n <number> <file>: Prints the first lines of a file.
    • tail -n <number> <file>: Prints the last lines of a file.
    • sort <file>: Sorts the lines of a file lexicographically.
    • sort -r <file>: Sorts the lines of a file in reverse lexicographical order.
    • sort -k <column> <file> [options]: Sorts the lines of a file based on the specified column.
    • cut -d <delimiter> -f<column_range> <file>: Extracts the specified columns from a file.
    • grep <pattern> <file>: Searches for lines containing a pattern in a file.
    • grep -i <pattern> <file>: Searches for lines containing a pattern in a file, ignoring case.
    • grep -v <pattern> <file>: Searches for lines not containing the pattern in a file.
    • find <directory> -name <pattern>: Searches for files with names matching a pattern in the specified directory and subdirectories.
    • find <directory> -iname <pattern>: Searches for files with names matching a pattern in the specified directory and subdirectories, ignoring case.
    • type <command>: Checks if a command is a built-in command, function, or an external command.
    • type -a <command>: Displays all commands matching the given pattern.
    • compgen -k: Lists all keywords available in bash.
    • man <command>: Displays the manual page for a command.
    • help <command>: Displays the help page for a command.
    • echo <string>: Displays a string to the terminal.
    • echo -n <string>: Displays a string to the terminal without a newline character.
    • chmod <permissions> <file>: Changes the file permissions.
    • chown <user>:<group> <file>: Changes the owner and group of a file.
    • chgrp <group> <file>: Changes the group of a file.
    • assert <condition> [, <message>]: Checks if a condition is true; if not, it raises an exception.
    • !!: Repeats the previous command.
    • >: Redirects standard output to a file (overwrites).
    • &gt;&gt;: Redirects standard output to a file (appends).
    • 2&gt;: Redirects standard error to a file.
    • 2&gt;&gt;: Redirects standard error to a file (appends).
    • &lt;: Redirects standard input from a file.
    • |: Pipes the output of one command as input to another.

    Python

    • assert <expression>, <message>: Checks if the expression is true. Raises an AssertionError if not.
    • import <module>: Imports a module
    • dir(<object>): Lists the attributes and methods of an object.
    • help(<object>): Prints the help information about an object.
    • open(<file_path>, <mode>): Opens a file.
    • read(): Reads the entire content of a file into a string.
    • readlines(): Reads all lines of a file into a list of strings.
    • write(<string>): Writes a string to a file.
    • writelines(<list>): Writes multiple strings (from a list) to a file.
    • close(): Closes an open file.
    • zip(<iterable1>, <iterable2>, ...): Creates an iterator that aggregates elements from multiple iterables.
    • enumerate(<iterable>): Creates an iterator that contains (index, value) tuples.
    • math.sqrt(<number>): Calculates the square root of a number.
    • iter(<iterable>): Returns an iterator from an iterable.
    • next(<iterator>): Returns the next item from an iterator.
    • itertools.repeat(<item>, <n>): Creates an iterator that repeats an item times.
    • itertools.product(<iterable1>, <iterable2>,...): Creates an iterator that outputs all ordered combinations of items in multiple iterables.
    • itertools.combinations(<iterable>, <size>): Creates an iterator that outputs all ordered combinations of items in an iterable, without repeating items.
    • itertools.combinations_with_replacement(<iterable>, <size>): Creates an iterator that outputs all ordered combinations of items in an iterable, allowing repeating items.
    • itertools.permutations(<iterable>, <size>): Creates an iterator that outputs all possible ordered sequence of items in an iterable
    • time.perf_counter(): Gets the performance counter time.
    • timeit(<statement>): Calculates execution time of statements

    Pandas

    • df.head(): Displays the first few rows of a DataFrame.
    • df.tail(): Displays the last few rows of a DataFrame.
    • df.dtypes: Displays the data types of each column.
    • df.shape: Returns the dimensions of the DataFrame as a tuple (rows, columns).
    • df.size: Returns the total number of elements in the DataFrame.
    • df.info(): Provides a concise summary of the DataFrame.
    • df.describe(): Generates descriptive statistics of numeric columns (count, mean, std, min, 25%, 50%, 75%, max).
    • df.columns: Returns the column labels as a pandas Index object.
    • df.index: Returns the index labels of a dataframe.
    • df.iat(<row>, <column>): Access a single cell by integer location (fastest way to select 1 value).
    • quizgecko.comdf.iloc(<row>, <column>): Access a single cell by integer location (slower than iat for selecting 1 value).quizgecko.com
    • df.loc[:, <column name>]: Selects a whole column by column name.quizgecko.com
    • df.loc(<row_label1>,<column_label2>): Selects whole rows/columns if they have labelquizgecko.coms.
    • df.drop(): Removes rows or columns.
    • df.set_index(): Sets an existing column as the DataFrame index.
    • df.reset_index(): Resets the index to a default integer index.
    • df.sort_values(): Sorts the values of a column.
    • df.sort_index(): Sorts the index values of a DataFrame.
    • df.explode(): Explode a column of list-like items into multiple rows.
    • df.fillna(): Fills missing values in a column.
    • df.query(): Filters rows based on a query string.
    • df.isin(): Filters rows where column values are present in a list (similar to SQL's IN).
    • df.value_counts(): calculates the occurrence of each unique value in a series
    • df.agg(): Applies multiple aggregation methods to columns within a groupby operation.quizgecko.com

    Studying That Suits You

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

    Quiz Team

    Related Documents

    AllMighty.txt PDF

    Description

    Test your knowledge on octal numbers and Python dictionaries in this quiz! You will answer questions about the syntax of octal numbers, conversions between number systems, and dictionary characteristics. Perfect for those learning Python programming.

    More Like This

    Master the Octal Number System
    6 questions
    Binary and Octal Number Systems
    20 questions
    Octal Number System Basics
    6 questions
    Use Quizgecko on...
    Browser
    Browser