Podcast
Questions and Answers
Which Python syntax correctly represents an octal number?
Which Python syntax correctly represents an octal number?
Which of the following is NOT a valid way to define an octal number in Python?
Which of the following is NOT a valid way to define an octal number in Python?
What is the decimal equivalent of the octal number 17?
What is the decimal equivalent of the octal number 17?
Given the octal number 12, what is its binary equivalent?
Given the octal number 12, what is its binary equivalent?
Signup and view all the answers
Which function would you use to convert a decimal number to octal in Python?
Which function would you use to convert a decimal number to octal in Python?
Signup and view all the answers
What is the primary characteristic of the data structure described?
What is the primary characteristic of the data structure described?
Signup and view all the answers
How are items populated in this data structure?
How are items populated in this data structure?
Signup and view all the answers
What happens to the items in this data structure related to uniqueness?
What happens to the items in this data structure related to uniqueness?
Signup and view all the answers
How does this data structure treat its elements?
How does this data structure treat its elements?
Signup and view all the answers
When defining this data structure, which of the following is true?
When defining this data structure, which of the following is true?
Signup and view all the answers
What does the statement d['Ali'] = 20 represent in the context of a dictionary?
What does the statement d['Ali'] = 20 represent in the context of a dictionary?
Signup and view all the answers
Which of the following statements is true regarding dictionary keys?
Which of the following statements is true regarding dictionary keys?
Signup and view all the answers
What is the primary characteristic of an empty string in terms of memory usage?
What is the primary characteristic of an empty string in terms of memory usage?
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?
If d is a dictionary, what will d.get('Ali') return if 'Ali' does not exist in the dictionary?
Signup and view all the answers
How can you ensure that all keys in a dictionary are of the same data type?
How can you ensure that all keys in a dictionary are of the same data type?
Signup and view all the answers
What does MRO stand for in the context of class relations?
What does MRO stand for in the context of class relations?
Signup and view all the answers
Which of the following concepts is related to inheritance in programming?
Which of the following concepts is related to inheritance in programming?
Signup and view all the answers
In programming, what is a characteristic of multiple inheritance?
In programming, what is a characteristic of multiple inheritance?
Signup and view all the answers
Which of the following statements best describes the concept of composition?
Which of the following statements best describes the concept of composition?
Signup and view all the answers
What is a potential issue that can arise from multiple inheritance?
What is a potential issue that can arise from multiple inheritance?
Signup and view all the answers
What is the purpose of the append
method in programming?
What is the purpose of the append
method in programming?
Signup and view all the answers
How can we generate multiples of 3 between 3 and 999 in Python using one line of code?
How can we generate multiples of 3 between 3 and 999 in Python using one line of code?
Signup and view all the answers
What is a significant property of the range
function in Python?
What is a significant property of the range
function in Python?
Signup and view all the answers
Which of the following descriptions about the range
function is incorrect?
Which of the following descriptions about the range
function is incorrect?
Signup and view all the answers
Which of the following statements is true regarding range creation?
Which of the following statements is true regarding range creation?
Signup and view all the answers
What functionality does the 'in' operator provide in Python?
What functionality does the 'in' operator provide in Python?
Signup and view all the answers
Which of the following correctly describes the syntax for using the 'in' operator?
Which of the following correctly describes the syntax for using the 'in' operator?
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]?
What would be the outcome of evaluating 'a in b' if a is 5 and b is a list containing [1, 2, 3]?
Signup and view all the answers
Which of the following statements is true when using the 'in' operator with strings?
Which of the following statements is true when using the 'in' operator with strings?
Signup and view all the answers
How does the 'in' operator behave when used with dictionaries in Python?
How does the 'in' operator behave when used with dictionaries in Python?
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). -
>>
: Redirects standard output to a file (appends). -
2>
: Redirects standard error to a file. -
2>>
: Redirects standard error to a file (appends). -
<
: 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.
Related Documents
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.