WWW Programming - 2
45 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 characteristic is generally associated with compiled languages?

  • Slower execution speed.
  • Powerful syntax checking at compile time. (correct)
  • Easier to debug runtime errors.
  • Best suited for small, single-person projects.
  • In contrast to compiled languages, interpreted languages tend to have which of the following?

  • Faster execution because of pre-compilation.
  • Ideal for large programs developed by teams.
  • More extensive syntax checking.
  • Errors detected mainly during runtime. (correct)
  • What is a primary focus of object-oriented programming?

  • Centering software design on data and objects. (correct)
  • Writing very small, basic programs.
  • Manipulating logic and functions over data.
  • Organizing software design around functions.
  • Which of the following can be defined as a blueprint for objects in OOP?

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

    What does the term 'instance' refer to in the context of OOP?

    <p>An object created from a specific class.</p> Signup and view all the answers

    In object-oriented programming, what is the purpose of methods?

    <p>Describe the behaviors of an object.</p> Signup and view all the answers

    Which of these are better suited for large projects with a lot of data and developed by teams?

    <p>Compiled Languages</p> Signup and view all the answers

    In object-oriented programming, what is the term for subroutines contained within the object?

    <p>Instance methods</p> Signup and view all the answers

    Which SQL statement is used to remove a table from a database?

    <p>DROP TABLE</p> Signup and view all the answers

    What does the SQL keyword SELECT primarily do?

    <p>Retrieves data from one or more tables</p> Signup and view all the answers

    Which clause in a SELECT statement specifies the table from which to retrieve data?

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

    What is the purpose of using the DISTINCT keyword in a SQL SELECT statement?

    <p>To retrieve only unique values in a specific column.</p> Signup and view all the answers

    What is the function of the asterisk (*) in a SELECT statement?

    <p>It indicates to select all rows and columns</p> Signup and view all the answers

    What SQL keyword is used to eliminate duplicate rows from the result set of a query?

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

    Given an Orders table with columns Company and OrderNumber, what would the following SQL query return: SELECT DISTINCT OrderNumber FROM Orders?

    <p>A list of unique order numbers.</p> Signup and view all the answers

    Which SQL statement is used to add a new column to an existing table?

    <p>ALTER TABLE</p> Signup and view all the answers

    What is the primary function of the WHERE clause in a SQL SELECT statement?

    <p>To filter records based on specified conditions.</p> Signup and view all the answers

    Which of the following SQL keywords is used to sort the result set of a query?

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

    Using the given Authors table, what would the following SQL query return: SELECT * FROM Authors WHERE YearBorn < 1968?

    <p>All authors born before 1968.</p> Signup and view all the answers

    If you wanted the complete record for every author born in 1969 from the Authors table, which SQL query would you use?

    <p><code>SELECT * FROM Authors WHERE YearBorn = 1969</code></p> Signup and view all the answers

    What does the WHERE keyword in a SELECT statement allow you to do?

    <p>Filter the rows that match a condition</p> Signup and view all the answers

    Which data structure is best suited for storing a collection of different data types?

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

    What is the key syntactic difference when defining a single-element tuple versus a single-element list in Python?

    <p>Tuples require a trailing comma <code>(element,)</code>, while lists do not.</p> Signup and view all the answers

    Which of the following best describes the mutability of tuples?

    <p>Tuples are immutable, meaning their contents cannot be changed after creation.</p> Signup and view all the answers

    If my_tuple = ('a', 'b', 'c'), what will happen if you try my_tuple[1] = 'x'?

    <p>Python will throw an TypeError because tuples are immutable.</p> Signup and view all the answers

    Considering my_list = ['apple'] and my_tuple = ('apple',), what happens if my_list = 'orange' and my_tuple = 'orange'?

    <p><code>my_list</code> becomes <code>['orange']</code> and assigning to <code>my_tuple</code> will produce an error.</p> Signup and view all the answers

    Which statement best differentiates how lists and dictionaries behave when they are assigned a new value?

    <p>Lists and dictionaries can be reassigned different types, showing their mutable behavior.</p> Signup and view all the answers

    If my_str = 'hello', what will happen when my_str = 'world' is executed?

    <p><code>my_str</code> will be reassigned to the string <code>'world'</code>.</p> Signup and view all the answers

    Which data type is immutable similar to a tuple.

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

    What is the output of the following code snippet?

    a = 1
    while a < 5:
        print(a)
        a += 1
    

    <p>1 2 3 4</p> Signup and view all the answers

    What does the break statement do within a loop?

    <p>It terminates the entire loop immediately.</p> Signup and view all the answers

    What is the purpose of the continue statement in a loop?

    <p>It skips the rest of the current iteration and proceeds to the next iteration.</p> Signup and view all the answers

    What would be the value of fact after the following code executes?

    fact, mul = 1, 2
    while mul < 10:
        fact, mul = fact * mul, mul + 1
        print(fact)
    

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

    In the given code, what is printed when a equals 3?

    a=0
    while a < 5:
        a += 1
        if a == 3:
            print ('My favorite number is ', a)
            continue
        print('a = ', a)
    

    <p><code>My favorite number is 3</code></p> Signup and view all the answers

    What is the final value of b after the following code executes?

    a, b = 1, 1 
    while a < 5: 
       print('a =', a) 
       a += 1 
       while b < 5: 
           print('b =', b) 
           if b == 2: 
              b=1
              break
           b += 1
    

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

    Which of the following best describes what multiple assignment is, as shown in the example fact, mul = 1, 2?

    <p>Assigning multiple values to multiple variables simultaneously.</p> Signup and view all the answers

    Which of these statements is true about for loops based on the text?

    <p><code>break</code> and <code>continue</code> statements can be used inside a <code>for</code> loop.</p> Signup and view all the answers

    What is one advantage of using a database for web data storage over data files?

    <p>Faster access capabilities</p> Signup and view all the answers

    Which of the following is a significant benefit of using databases in web applications?

    <p>Easier modifications to data and scripts</p> Signup and view all the answers

    Why is MySQL commonly used with Python?

    <p>It is free and has built-in functions for interface</p> Signup and view all the answers

    What factor enhances the security of a database system?

    <p>Separate user ID and password for database access</p> Signup and view all the answers

    What is a feature of MySQL Connector Python?

    <p>It is self-sufficient for executing database queries</p> Signup and view all the answers

    To connect to a MySQL database using Python, which of the following is essential?

    <p>Detailed information about the MySQL server</p> Signup and view all the answers

    What is an advantage of using a database regarding concurrent user access?

    <p>Better concurrent access than file storage applications</p> Signup and view all the answers

    Which of the following describes a characteristic of MySQL Connector Python?

    <p>It is an official Oracle-supported driver</p> Signup and view all the answers

    Study Notes

    Introduction to Network and Web Application

    • The presentation is about introducing network and web applications.
    • Topics include programming languages, internet history, WWW Consortium, and network architecture.

    Programming Languages

    • Computer programming languages are sets of instructions for digital computers.
    • Machine language is the numerical form directly executed by a computer.
    • Assembly language is a low-level language using mnemonics for instructions, easier to understand than machine language.
    • High-level languages (e.g., FORTRAN, ALGOL, LISP, C) are designed for mathematical or symbolic computations, using notations more like mathematics. They reuse subprograms, which package commonly used operations.

    Machine Language

    • Machine language consists of numerical codes of operations.
    • Uses binary digits ("bits"), often converted to hexadecimal for easier human viewing.
    • Instructions use some bits for operations (e.g., addition) and others for operands.
    • Difficult to read and write.
    • Codes vary from computer to computer.

    Advantages of Machine Language

    • Fast and efficient computer use.
    • No translator required, directly understood by the computer.

    Disadvantages of Machine Language

    • Operation codes and memory addresses must be remembered.
    • Finding errors is difficult.
    • Machine language is not widely used.

    Assembly Language

    • Assembly language is one level above machine language.
    • Uses mnemonic codes for instructions and names for memory blocks.
    • Designed for easy translation into machine language.
    • Programs are compiled by an assembler.
    • Each assembler has its own assembly language for a specific architecture.

    Assembly Language (continued)

    • Requires detailed knowledge of internal computer architecture.
    • Useful when computer interaction with I/O devices is important.
    • Simple programs can be written, like simple input/output programs, which read from and output to ports.

    Machine and Assembly Languages: Example

    • Shows a table comparing machine and assembly code with their descriptions.
    • Machine code and assembly instructions for operations like loading numbers, storing, and adding.

    Machine and Assembly Languages (More…)

    • Machine language is difficult to read; it consists entirely of numbers.
    • Assembly language is easier to read than machine language, using words to represent the operations.
    • Shows examples of machine and assembly languages.

    Algorithmic Languages

    • FORTRAN, ALGOL, and LISP are examples.
    • Designed to express mathematical and symbolic computations.
    • Allow use of subprograms that package commonly used functions, offering reuse.
    • First high-level languages.

    FORTRAN

    • First popular high-level language.
    • Designed for scientific calculations using real numbers.
    • Has conditional statements (IF), repetitive loops (DO), GOTO.
    • Made it easy for mathematical operations, building libraries of subroutines.
    • Quickly translated into machine language and developed.

    ALGOL

    • Designed by a committee of European and American computer scientists—to enable publishing of algorithms.
    • Included recursive subprograms (procedures that call themselves) for solving problems by reducing them to smaller similar problems.
    • Contains block structure (programs composed of blocks with data and instructions, having the same structure as an entire program).

    LISP

    • Developed in 1960 by John McCarthy at MIT.
    • Used recursive functions in mathematical theory to express a program as a function applied to data.
    • Uses a very simple, parenthesized notation for operations.

    C

    • Developed in 1972 by Dennis Ritchie and Brian Kernighan at AT&T Corporation for computer operating systems.
    • Structured data and programs into smaller units like ALGOL.
    • A compact notation allows programmers to use data and address values directly.
    • Important in systems programming.

    Business-Oriented Languages

    • COBOL is a common language for business computing.
    • Designed by a committee (CODASYL) to be consistent and portable across different computer manufacturers.
    • Uses English-like notations for business data and calculations, organizing and manipulating large data elements.
    • Introduced the record structure.

    SQL

    • Structured Query Language
    • Language for defining the organization of databases.
    • Queries can be used to retrieve information from a specific database item or collection of items.
    • Most commercial database programs use a SQL-like language for their queries.

    Education-Oriented Languages

    • BASIC (Beginner's All-purpose Symbolic Instruction Code), designed for newbies, especially non-computer science majors.
    • Simple instructions and data structures.
    • LOGO, HYPERTALK – designed for education purposes.
    • Pascal – an imperative and procedural language.

    Types of Programming Languages

    • High-level language
    • Assembly language  – increasing use quickly
    • Need for compilers that translate high level languages to machine language
    • Very similar to everyday English
    • Scripts are created for shortening the compile-link-run process
    • Interpreters are simpler than compilers

    Compiling and Running Your Program

    • Every machine has its own machine codes.
    • High-level programming languages are translated to assembly code by compilers, and assembly code is translated to machine code by operating systems when running the program.

    Translator Programs: Assembler vs Compiler vs Interpreter

    • Assembler
    • Use in assembly languages
    • Converts assembly language program to machine language
    • Compilers
    • Use in high-level languages
    • To speed up programming process
    • Converts high-level languages to machine language Faster than interpreters
    • Interpreters
    • Use in high-level languages
    • Execute high-level languages directly without compiling Program is recompiled as new features are added and errors corrected

    Different Programming Languages

    • Machine language, assembly language, and high-level language example using the "Hello World" output.

    Properties of Web Languages–Compiled languages

    • Java, C, and C++ are examples of compiled languages
    • Type languages; every identifier has a fixed data type
    • Compiler scans the entire program, writing machine (or virtual machine in Java) language to execute operations.
    • Code generated before program runs and checks for data types.

    Properties of Web Languages–Interpreted languages

    • JavaScript, JScript, VBScript, Perl, PHP, and Python
    • The interpreter executes code line by line as the data flows.
    • Not compiled into machine language before execution.

    Compiled vs Interpreted Languages

    • Compiled languages are faster in execution (although Java is slower because it has an intermediate virtual machine step), use powerful syntax checking, and are best for large programs.
    • Interpreted languages are easier to write, are better for smaller programs, but are slower.

    Difference between Compiled and Interpreted Languages

    • Compiled languages are compiled to machine code before they're run, interpreted languages are executed line by line.
    • Compiled languages frequently have better performance than interpreted languages, are more complex.

    Object-Oriented Languages

    • OOP is a programming model that organizes software design around data.
    • Focuses on objects instead of logic to manipulate them.
    • Well suited for large, complex programs.
    • Common usages include manufacturing, design, mobile, etc.

    OOP: Structure

    • Class: blueprint for objects
    • Objects: instances of a class with defined data
    • Methods: functions inside a class that describe object behaviors.
    • Attributes: properties that define the state of an object

    OOP Principles

    • Abstraction
    • Encapsulation
    • Inheritance
    • Polymorphism

    Object-Oriented Programming (OOP) Languages

    • Popular pure OOP languages include Ruby, Scala, JADE, Emerald
    • Programming languages designed primarily for OOP include Java, Python, and C++
    • Other programming languages that can be used with OOP include VB.NET, PHP, JavaScript.

    What are the Benefits of OOP

    • Modularity: Objects are self-contained, making troubleshooting easier.
    • Reusability: Code reusability by inheritance.
    • Productivity: Quicker program construction from libraries or reusable code.
    • Easily Upgradable: System functionalities can be implemented independently.
    • Interface Descriptions: Communication between external systems is simple and message passing.
    • Security: Internal code is hidden (encapsulation), and security is enhanced using protocols.
    • Flexibility: Adapting single function for various classes using polymorphism.

    Criticism of OOP

    • Often overemphasizes data component of software development at the expense of computation or algorithms.
    • OOP code can be more complex to write and take longer to compile.

    Web Languages Examples

    • Client side: JavaScript, JScript, VBScript, HTML, DHTML, AJAX, jQuery, TypeScript, ActionScript, React, Angular, Vue, Swift, SASS, Elm
    • Server side: Active Server Pages (ASP), Java Server Pages (JSP), ColdFusion, IPTSCRAE, Lasso, MIVA Script, PHP, ASP.NET, SMX, XSLT, Ruby, Python, Node.js, Perl, C#

    Different Programming Languages

    • Shows comparison using examples like machine code, assembly code and high level languages.

    Programming Paradigms

    • Shows a complex diagram of the different programming paradigms (imperative, logic, functional).

    Future of Internet Computing

    • Focus on mobile (GSM, 5G, etc.) technologies, interactive/multimedia (3D, VR, etc.) technologies, cyber-physical systems, and the Internet of Things.

    Introduction to the Internet

    • TCP/IP is the communication protocol on the Internet.
    • Defines the rules for communication between computers over the internet
    • Used by browsers and servers for communication to send HTML.
    • Used for sending and receiving e-mails
    • Part of the standard TCP/IP protocol (e.g., the IP address)

    Internet Protocol

    • The Internet Protocol (IP)
    • A protocol for communication in an internetwork using the Internet Protocol Suite (TCP/IP)
    • Responsible for delivering data packets (datagrams) from source host to destination host based on addresses.
    • IP addresses are like personal names, assigned as numeric addresses (e.g., IPv4 - 32-bit number like 131.123.35.92) or (IPv6 - 128-bit number)

    Internet Protocol (cont.)

    • IPv6 address (in hexadecimal) example: 2001:0DB8:AC10:FE01:0000:0000:0000:0000 (zeros can be omitted 2001:0DB8:AC10:FE01::)
    • Table shows comparison on IPv4 and IPv6 headers, which fields are kept and changed.

    Domain Names

    • Textual names for machines on the internet.
    • Host machine name called Domain.
    • Multiple domain names are possible.
    • The last domain name identifies the type of organization.
    • Example : www.uum.edu.my

    Domain Names (cont.)

    • Domain names translate to numerical IP addresses via a Domain Name Server (DNS).
    • Diagram shows the flow of the conversion from domain name to IP address to retrieve the website's content.

    World Wide Web

    • Created by Tim Berners-Lee at CERN (Conseil Européen pour la Recherche Nucléaire).
    • Allows scientists across the world to exchange and retrieve documents from databases through hypertext (text embedded with links to other documents).
    • WWW is commonly known as "the Web."
    • A large collection of texts connected by hyperlinks. Documents are accessed via web browsers and are provided by web servers.

    Internet vs. Web

    • The internet is a network of networks.
    • The web is a collection of software (software and protocols).
    • The web is part of the internet for publishing and information exchange.

    Terminologies

    • Client: program that initiates communication
    • Server: program that responds to the client's request.
    • Web Browser: software run by clients
    • Web Server: software run by server that responds to the clients
    • URL: identifies the documents or resources on the Internet. Formats are Scheme, object address, and default web server port number (80).
    • HTTP: communication protocol, two phases - request and response. The message is separated into two parts - Header: information about the communication and Body: the data of the communication

    Client and Server

    • Client initiates communication with a server. The server then sends information back to the client.
    • Client-side programs (e.g., JavaScript) run on the client's workstation.
    • Server-side programs (e.g., PHP, Python) run on the server.

    Web Servers

    • Programs providing documents to browsers.
    • Apache and IIS are common web servers.
    • Have document root and server root directories
    • Can interact with databases using CGI & server-side scripts.
    • Support protocols like FTP, Gopher, News and mail.

    URL - Uniform Resource Locators

    • Used to identify documents or resources on the Internet.
    • Contains the scheme, object address or communication protocols, and default web server port number.
    • Examples: http://www.uum.edu.my, http://www.google.com

    HTTP (Hypertext Transfer Protocol)

    • Formally defined in RFC 2616.
    • Consists of requests and responses; both are divided into a Header (information) and a Body (data). -Each HTTP communication between browsers and web servers has two parts.

    Markup Languages

    • Markup languages such as HTML, DHTML, HTML4.0, and HTML5, XML, and CSS; they have a major impact on the role of web languages. -Markup languages continue to develop giving more power to client-side web languages, such as JavaScript.

    Markup Languages Characterization

    • Hypertext Markup Language (HTML): Specifies how a document is presented, and how documents cross-reference each other.
    • Web succeeds because it is open and free standard. It has simple tags and uses simple text editors. It is platform independent for publishing and presentation and is easy to learn.
    • Cascading Style Sheets (CSS): make dynamic HTML possible by allowing users to add style sheets for appearance elements, such as color, font, position, and visibility.
    • Extensible Markup Language (XML): A markup language concerned with content instead of appearance; used to add structure and organization to data on websites.
    • XHTML: Essentially HTML4 and conforms to stricter XML formatting.

    World Wide Web Consortium (W3C)

    • Standardisation organization for web technologies.
    • Established to regulate the development of web technologies like HTTP, HTML, and XML, ensuring widespread accessibility and consistency.
    • Example recommendations are for XHTML, CSS, HTML, and XML.

    Network Architecture

    • Design for communication networks.
    • Physical components, functional organization, policies, procedures, and data formats.

    OSI Network Model

    • Open Systems Interconnection Model for network architecture.

    Machine & Assembly Languages

    • Summary of programming languages—from machine language, assembly language, to high-level programming languages like FORTRAN, ALGOL and LISP to C.

    Properties of Web Languages (continued)

    • Compiled and interpreted languages
    • Object-oriented languages—defined by classes, objects, methods, and attributes.

    Server Side Languages

    • Server-side languages like PHP, Python, and Ruby; often used with web servers to handle database interactions and create dynamic web pages. Explain their purposes and use cases.

    More Information

    • Additional details including web technologies

    Studying That Suits You

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

    Quiz Team

    Related Documents

    WWW Programming PDF

    Description

    Test your knowledge on object-oriented programming concepts and SQL syntax. This quiz covers fundamental characteristics of compiled vs. interpreted languages, the principles of OOP, and common SQL commands. Perfect for students reviewing programming fundamentals.

    More Like This

    Use Quizgecko on...
    Browser
    Browser