Python Scripting Language W04IST-SI4011
40 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 does Python use instead of brackets?

  • Parentheses
  • Commas
  • Indentation (correct)
  • Semicolons
  • What is the recommended number of spaces to use for indentation in Python?

  • 4 (correct)
  • 16
  • 2
  • 8
  • What command can be used to run a Python script called app.py?

  • execute app.py
  • python app.py (correct)
  • run app.py
  • py app.py (correct)
  • What tool can be used to check Python code for compliance with PEP8?

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

    What is the command to install pycodestyle using pip?

    <p>pip install pycodestyle</p> Signup and view all the answers

    What does PEP stand for?

    <p>Python Enhancement Proposal</p> Signup and view all the answers

    What is the presence requirement for lectures in this course?

    <p>Presence is not obligatory</p> Signup and view all the answers

    What type of test can be expected in the final exam?

    <p>Multiple-choice or single-answer test</p> Signup and view all the answers

    What is the minimum score required to pass the final exam?

    <p>50% of total points</p> Signup and view all the answers

    How can students access valuable books for this course?

    <p>By creating a user account in Safari Books Online service</p> Signup and view all the answers

    What is the policy on cheating and plagiarism in labs?

    <p>It is strictly prohibited</p> Signup and view all the answers

    What is the requirement for lab completion?

    <p>Ability to explain code</p> Signup and view all the answers

    How can students select their institution in Safari Books Online service?

    <p>From a drop-down list</p> Signup and view all the answers

    What is the consequence of cheating in the course?

    <p>The student is removed from the course</p> Signup and view all the answers

    What is the feature of Python environment that makes it a 'batteries included' environment?

    <p>It includes a vast collection of libraries and tools</p> Signup and view all the answers

    What is the purpose of the 'pip' command in Python?

    <p>To manage dependencies and libraries in Python</p> Signup and view all the answers

    What is the main difference between IPython and Jupyter Notebook?

    <p>IPython is a command-line interface, while Jupyter Notebook is a web-based interface</p> Signup and view all the answers

    What is the purpose of the 'conda' command in Anaconda?

    <p>To manage dependencies and libraries in Python</p> Signup and view all the answers

    What is the extension of a Python file?

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

    What is the purpose of the 'shebang' line in a Python file?

    <p>To specify the interpreter to use</p> Signup and view all the answers

    What is the feature of IDLE that makes it a good Integrated Development Environment (IDE)?

    <p>It has syntax highlighting</p> Signup and view all the answers

    What is the difference between Python and IPython?

    <p>IPython adds extra features to the Python shell</p> Signup and view all the answers

    What is the main difference between Jupyter Notebook and Python?

    <p>Jupyter Notebook is a web-based interface, while Python is a command-line interface</p> Signup and view all the answers

    What is the purpose of the 'pylint' command in Python?

    <p>To check the code for errors and style</p> Signup and view all the answers

    What is the syntax to print a statement in Python2?

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

    What is the data type of a complex number in Python?

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

    What is the purpose of the input function in Python?

    <p>To read data from input</p> Signup and view all the answers

    What is the keyword used to define a function in Python?

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

    What is the purpose of the return keyword in Python?

    <p>To return the result of a function</p> Signup and view all the answers

    What is the purpose of the pass keyword in Python?

    <p>To indicate an empty body</p> Signup and view all the answers

    What is the purpose of the range function in Python?

    <p>To generate a list of numbers</p> Signup and view all the answers

    What is true about everything in Python?

    <p>Everything is an object</p> Signup and view all the answers

    What is the main purpose of Python Enhancement Proposals (PEPs)?

    <p>To describe new function proposals and guidelines</p> Signup and view all the answers

    Which of the following is a characteristic of Python as a dynamically-typed language?

    <p>It allows variables to change type during runtime</p> Signup and view all the answers

    What is the principle of Python design that states 'Readability counts'?

    <p>Readability counts</p> Signup and view all the answers

    What is the output of the code print("Hello, {}!".format("World"))?

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

    What is an advantage of Python being a multi-paradigm language?

    <p>It allows developers to choose the best approach for a problem</p> Signup and view all the answers

    What is the main difference between Python and Java?

    <p>Python is dynamically-typed, while Java is statically-typed</p> Signup and view all the answers

    What is the error in the code 2 + '2'?

    <p>Type error: cannot add integer and string</p> Signup and view all the answers

    What is the purpose of the print() function in Python?

    <p>To output data to the console</p> Signup and view all the answers

    Study Notes

    Course Introduction

    • Course title: Script Languages (W04IST-SI4011)
    • Faculty: Faculty of Information and Communication Technology
    • Department: Department of Applied Informatics
    • Teachers: Wojciech Thomas, PhD
    • Course completion conditions: Get passing grades from lab exercises, pass the final exam, and follow the cheating and plagiarism policy

    Lecture and Lab Completion

    • Lecture activities: Ad hoc, random, and no negative points
    • Lab completion conditions: Presence is obligatory, create a user account in Safari Books Online, follow the cheating and plagiarism policy, and demonstrate ability to explain code and write clean code

    Python Resources

    • Python DOCS: https://www.python.org/doc/
    • Recommended books: Learning Python, Impractical Python Projects, and Automate the Boring Stuff with Python
    • Python flavors: Python, IPython, Jupyter Notebook, and Anaconda

    Python Environment

    • Python is a "batteries included" environment with a distribution made by Python developers
    • Dependency management with pip: pip install, pip install --upgrade, and python -m pip install --upgrade pip
    • IPython adds extra functions to Python shell, including syntax highlighting, help, variables introspection, magic commands, and TAB completion

    Python Code File

    • Python files use .py extension
    • On Windows, .py extension suggests a tool to run the code
    • On Linux/iOS, you need to add a "shebang" line: #!/usr/bin/python
    • You can run an app using py: py app.py

    Code Layout and Style

    • Python uses indentation instead of brackets
    • It is advised to use spaces instead of Tabs
    • pycodestyle checks your code for compliance with PEP8
    • Install pycodestyle with pip: pip install pycodestyle

    PEP

    • PEP ≡ Python Enhancement Proposal
    • A set of documents describing new functions proposals, guidelines, and process descriptions
    • PEP20 (The Way of Python) includes 20 principles of Python design

    Multi-Paradigm Language

    • Python is a multi-paradigm language, allowing structured, object-based, and functional programming
    • Python is dynamically-typed, but strongly-typed language

    Variables and Output

    • Python is dynamically-typed: >>> id = 12, >>> type(id), >>> id = "ad3ez79", >>> type(id)
    • print is a function used to output data: >>> print("Hello!"), >>> print("Hello, {}!".format("World"))
    • input is a function to read data from input: >>> name = input("Please, type your name:")

    Basic Types

    • Integer: int, bool
    • Floating point: float (double precision)
    • Complex numbers: complex (e.g., z: z.real and z.real)
    • String: a sequence type (see: next lecture)

    Conditions and Functions

    • if keyword executes part of the code conditionally
    • return keyword returns the result of the function
    • def keyword defines a function: def sum(a, b): return a+b

    Loops and Objects

    • for keyword loops through the values
    • range function generates a list of numbers
    • Everything in Python is an object, including functions, values, types, and classes

    Studying That Suits You

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

    Quiz Team

    Related Documents

    Description

    Learn the basics of Python scripting language in this course for students of Department of Applied Informatics. Understand the fundamentals of Python programming and its applications.

    More Like This

    Python Basics
    5 questions

    Python Basics

    SpotlessJadeite421 avatar
    SpotlessJadeite421
    Python Programming Language Basics
    14 questions
    Use Quizgecko on...
    Browser
    Browser