Podcast
Questions and Answers
What does Python use instead of brackets?
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?
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?
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?
What tool can be used to check Python code for compliance with PEP8?
What is the command to install pycodestyle using pip?
What is the command to install pycodestyle using pip?
What does PEP stand for?
What does PEP stand for?
What is the presence requirement for lectures in this course?
What is the presence requirement for lectures in this course?
What type of test can be expected in the final exam?
What type of test can be expected in the final exam?
What is the minimum score required to pass the final exam?
What is the minimum score required to pass the final exam?
How can students access valuable books for this course?
How can students access valuable books for this course?
What is the policy on cheating and plagiarism in labs?
What is the policy on cheating and plagiarism in labs?
What is the requirement for lab completion?
What is the requirement for lab completion?
How can students select their institution in Safari Books Online service?
How can students select their institution in Safari Books Online service?
What is the consequence of cheating in the course?
What is the consequence of cheating in the course?
What is the feature of Python environment that makes it a 'batteries included' environment?
What is the feature of Python environment that makes it a 'batteries included' environment?
What is the purpose of the 'pip' command in Python?
What is the purpose of the 'pip' command in Python?
What is the main difference between IPython and Jupyter Notebook?
What is the main difference between IPython and Jupyter Notebook?
What is the purpose of the 'conda' command in Anaconda?
What is the purpose of the 'conda' command in Anaconda?
What is the extension of a Python file?
What is the extension of a Python file?
What is the purpose of the 'shebang' line in a Python file?
What is the purpose of the 'shebang' line in a Python file?
What is the feature of IDLE that makes it a good Integrated Development Environment (IDE)?
What is the feature of IDLE that makes it a good Integrated Development Environment (IDE)?
What is the difference between Python and IPython?
What is the difference between Python and IPython?
What is the main difference between Jupyter Notebook and Python?
What is the main difference between Jupyter Notebook and Python?
What is the purpose of the 'pylint' command in Python?
What is the purpose of the 'pylint' command in Python?
What is the syntax to print a statement in Python2?
What is the syntax to print a statement in Python2?
What is the data type of a complex number in Python?
What is the data type of a complex number in Python?
What is the purpose of the input function in Python?
What is the purpose of the input function in Python?
What is the keyword used to define a function in Python?
What is the keyword used to define a function in Python?
What is the purpose of the return keyword in Python?
What is the purpose of the return keyword in Python?
What is the purpose of the pass keyword in Python?
What is the purpose of the pass keyword in Python?
What is the purpose of the range function in Python?
What is the purpose of the range function in Python?
What is true about everything in Python?
What is true about everything in Python?
What is the main purpose of Python Enhancement Proposals (PEPs)?
What is the main purpose of Python Enhancement Proposals (PEPs)?
Which of the following is a characteristic of Python as a dynamically-typed language?
Which of the following is a characteristic of Python as a dynamically-typed language?
What is the principle of Python design that states 'Readability counts'?
What is the principle of Python design that states 'Readability counts'?
What is the output of the code print("Hello, {}!".format("World"))
?
What is the output of the code print("Hello, {}!".format("World"))
?
What is an advantage of Python being a multi-paradigm language?
What is an advantage of Python being a multi-paradigm language?
What is the main difference between Python and Java?
What is the main difference between Python and Java?
What is the error in the code 2 + '2'
?
What is the error in the code 2 + '2'
?
What is the purpose of the print()
function in Python?
What is the purpose of the print()
function in Python?
Flashcards are hidden until you start studying
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.