Python Scripting Language W04IST-SI4011

InexpensiveVariable avatar
InexpensiveVariable
·
·
Download

Start Quiz

Study Flashcards

40 Questions

What does Python use instead of brackets?

Indentation

What is the recommended number of spaces to use for indentation in Python?

4

What command can be used to run a Python script called app.py?

python app.py

What tool can be used to check Python code for compliance with PEP8?

pep8

What is the command to install pycodestyle using pip?

pip install pycodestyle

What does PEP stand for?

Python Enhancement Proposal

What is the presence requirement for lectures in this course?

Presence is not obligatory

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

Multiple-choice or single-answer test

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

50% of total points

How can students access valuable books for this course?

By creating a user account in Safari Books Online service

What is the policy on cheating and plagiarism in labs?

It is strictly prohibited

What is the requirement for lab completion?

Ability to explain code

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

From a drop-down list

What is the consequence of cheating in the course?

The student is removed from the course

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

It includes a vast collection of libraries and tools

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

To manage dependencies and libraries in Python

What is the main difference between IPython and Jupyter Notebook?

IPython is a command-line interface, while Jupyter Notebook is a web-based interface

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

To manage dependencies and libraries in Python

What is the extension of a Python file?

.py

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

To specify the interpreter to use

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

It has syntax highlighting

What is the difference between Python and IPython?

IPython adds extra features to the Python shell

What is the main difference between Jupyter Notebook and Python?

Jupyter Notebook is a web-based interface, while Python is a command-line interface

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

To check the code for errors and style

What is the syntax to print a statement in Python2?

print 'Hello!'

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

complex

What is the purpose of the input function in Python?

To read data from input

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

def

What is the purpose of the return keyword in Python?

To return the result of a function

What is the purpose of the pass keyword in Python?

To indicate an empty body

What is the purpose of the range function in Python?

To generate a list of numbers

What is true about everything in Python?

Everything is an object

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

To describe new function proposals and guidelines

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

It allows variables to change type during runtime

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

Readability counts

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

Hello, World!

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

It allows developers to choose the best approach for a problem

What is the main difference between Python and Java?

Python is dynamically-typed, while Java is statically-typed

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

Type error: cannot add integer and string

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

To output data to the console

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

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.

Make Your Own Quizzes and Flashcards

Convert your notes into interactive study material.

Get started for free

More Quizzes Like This

Python Basics
5 questions

Python Basics

SpotlessJadeite421 avatar
SpotlessJadeite421
Python Essentials
5 questions
Use Quizgecko on...
Browser
Browser