Python and SQL Basics Quiz
24 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

What device is most suitable for connecting each computer in a cyber café?

  • Switch (correct)
  • Modem
  • Router
  • Server
  • What does SQL stand for?

  • Simple Query Language
  • Structured Query List
  • Structured Query Language (correct)
  • Standard Query Language
  • Which clause in a SELECT query specifies conditions for the rows returned?

  • Order By
  • Filter
  • Select
  • Where (correct)
  • Which function in MySQL is used to find the largest value in a dataset?

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

    Which data types create fixed and variable types of string fields in a database?

    <p>CHAR(n) and VARCHAR(n)</p> Signup and view all the answers

    What is the term used to refer to a record in a database table?

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

    Which method of cursor class is specifically used to fetch a limited number of rows from a table?

    <p>cursor.fetchmany(SIZE)</p> Signup and view all the answers

    Which command is specifically used to close a database connection in SQL with Python?

    <p>con.close</p> Signup and view all the answers

    What type of error results in an abrupt termination of a program when executing?

    <p>Runtime error</p> Signup and view all the answers

    What is the full form of DDL?

    <p>Data Definition Language</p> Signup and view all the answers

    Which of the following best describes an attribute derived from the primary key of another table?

    <p>Foreign key</p> Signup and view all the answers

    Which keyword in Python is NOT represented in lower case?

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

    In SQL, what clause would be used to group employee records by their designations?

    <p>GROUP BY</p> Signup and view all the answers

    Which statement accurately describes a logical error in programming?

    <p>The output is not what was expected.</p> Signup and view all the answers

    What is the primary benefit of computer networking?

    <p>File Sharing</p> Signup and view all the answers

    What keyword gives an inaccurate statement when reflecting on data collection structures in Python?

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

    What is the default order of the results when using the ORDER BY clause?

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

    Which attribute is the most suitable choice for a primary key?

    <p>Roll No</p> Signup and view all the answers

    What keyword should be inserted in the query: INSERT INTO employee____(1002, 'Kausar', 2000);?

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

    How would you write a SQL statement to select all students whose last names contain 5 letters ending with 'A'?

    <p>SELECT * FROM STUDENTS WHERE LNAME LIKE '____A';</p> Signup and view all the answers

    In the table structure Student (ID, name, dept name, tot_cred), which attribute is most appropriate to serve as the primary key?

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

    Which keyword should you use in the query to display the unique values of the column dept_name?

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

    To rename the field heading 'course_id' as 'id' in the query, which keyword should be used?

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

    What is the function of the HAVING clause in SQL?

    <p>Acts like a WHERE clause but is used for groups rather than rows.</p> Signup and view all the answers

    Study Notes

    Python File Extensions

    • The default extension for a Python file is .py

    Python Control Structures

    • Control structures in Python dictate the order of statement execution in a program.
    • They do not define data structures or handle program startup/termination.

    Python if Statement

    • A valid Python if statement is if x >= 9:

    Compile Time Errors

    • Compile time errors include syntax errors and semantic errors.

    Tuple Slicing

    • Given the tuple tup1 = (10, 20, 30, 40, 50, 60, 70, 80, 90), the output of print(tup1[3:7:2]) is (40, 60)

    String Concatenation

    • Concatenating strings 'p' and 'q' gives the result 'pq'

    Function Calls

    • Function calls like Calc(15, 25) and Calc(X=15, Y=25) are valid. Calc(Y=25) is only valid for optional parameters.

    SQL UPDATE

    • The command to change some values in existing rows in a SQL table is UPDATE.

    SQL Keywords

    • Invalid Python identifiers include break, section, and mark12.

    Relational Database Rules

    • Relational databases must comply with at least 6 rules.

    File Opening

    • Opening a text file 'Notes.txt' for writing in Python can use modes 'w', 'a', 'A', or 'w+'. Mode 'w' overwrites content, 'a' appends, 'A' is the same as 'a', 'w+' opens for read and write, with the prior contents being overwritten for write operations.

    Network Types

    • A peer-to-peer network has no servers.

    Modules for Serialization

    • The pickle module serializes Python objects.

    Database Connection Arguments

    • Mandatory arguments to connect a database from Python are username, password, hostname, database name, and port.

    Cursor Fetching

    • The cursor.fetchmany(SIZE) method fetches a limited number of rows from a table.

    Assertion and Reason

    • Assertion and Reason questions ask students to evaluate a statement of assertion (A) and a statement of reason (R). The correct choice depends on whether both statements are true and if reason is a correct explanation for assertion. (A), (B), (C), (D) are possible answers.

    Decision Making and Selection Statements

    • if-elif and if-else statements are decision-making statements. for statements are not.

    Loop Types

    • Python's for loop is an entry-controlled loop;

    List Brackets

    • [] are used to define a Python list.

    Function Definition Inside a Class

    • A function defined inside a class is called a method.

    Relational Database Components

    • Relational databases are collections of tables, each with records (rows) and fields (columns).

    File Object tell()

    • The tell() method in Python file objects returns the current byte position of the file pointer as an integer.

    Table Field

    • A field in a SQL table is also called an attribute.

    File Content Separators

    • Whitespace (spaces, tabs) commonly separate content in text files, however commas, tabs or others are possible.

    Aggregate Functions

    • The function JOIN is not an aggregate function.

    Network Switching Techniques

    • Switching mechanisms, including circuit, message, and packet switching, use differing strategies.

    Python Indices

    • In the list ["John", "Harry", "Jesse", "John", "Harry", "Harry"], the item at index 3 is "John".

    Cursor Methods for Database Functions

    • The method cursor.callproc is used to execute stored procedures in Python.

    SQL Query Result

    • The result of executing SQL query on a database connection is a result set.

    Properties of Mutable Objects

    • Strings in Python are immutable objects, meaning their values can't be changed. Conversely, lists are mutable.

    String Concatenation

    • Strings can be combined using the + operator.

    Invalid Python Identifiers

    • An example of an invalid identifier in Python is 2ndName.

    Arithmetic Operators

    • The arithmetic operators //, ?, <, and and are possible answers, depending on the context; however, // is common.

    Studying That Suits You

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

    Quiz Team

    Related Documents

    12th One Mark Questions PDF

    Description

    Test your knowledge on Python file extensions, control structures, and SQL commands. This quiz covers essential concepts such as the if statement, function calls, and string concatenation. Additionally, brush up on error types and valid identifiers in programming.

    More Like This

    Use Quizgecko on...
    Browser
    Browser