Lectures 5 to 6 - Revision Flashcards
(27 cards)
What is a SCRIPT?
A script is a set of statements written in proghramming language designed to perform a specific task and stored in a file.
The statements are executed one after the other until the script is finished
What is an IDE?
An Integrated Development Environment (IDE) is a software
application designed to help developers write, debug, test and
manage code. An IDE includes a code editor, a terminal interface
and a bunch of programming tools.
What is a SHELL?
A shell is a program that serves as an interface between a user and an operating system e.g Powershell
UNIX Commands: How do you display the current working directory in the terminal
pwd
(print working directory)
UNIX Commands: How do you use the terminal to display a list of files and or directories within a directory?
ls
to show the list in your current location just use ls
to specifiy a directory within your location use
ls directoryname
UNIX Commands: What does the .. symbol mean in the terminal?
.. represents the parent directory
. represents the current directory
UNIX Commands: How do you use the terminal to create a new directory?
mkdir thendirectoryname
(make directory)
UNIX Commands: How do you use the terminal to delete (remove) an empty directory?
rmdir thendirectoryname
(remove directory)
UNIX Commands: How do you delete (remove) files?
rm thenfilename
(remove)
UNIX Commands: How do you copy files or directories?
cp thendirectoryorfilename
(copy)
To copy and rename
cp filename.py newfilename.py
UNIX Commands: How do you move files or directories?
mv thendirectoryorfilename then destination location
(move)
If the file name is the same as one already existing in that directory the effect will be to rename it with copy.
UNIX Commands: How do you display the content of files?
cat thenfilename
UNIX Commands: How do you manage a file or directory name that has spaces in it?
Put the whole file or directory name in double quotation marks.
What is a Python Libray?
A Python Library is a collection of pre-written code made available to use.You can use them in your Python programs to perform specific tasks meaning you do not need to create them from scratch
What is the difference between a script and a program?
Both scripts and programs are sets of statements written in a programming language designed to perform specific tasks…. The words are often used interchangably. HOWEVER they are slightly different.
Typically SCRIPTS are:
- simpler
- usually for temporary tasks
- use a text interface terminal (programs use GUI)
- written in interpreted languages (Python, JavaScript or Bash) - whereas programs are written in compiled languages (e.g. Java, C++, C)
What are interpreters and interpreting languages?
Interpreters are software tools that processes and executes statements one at a time.
Interpreted languages are programming languages that execute instructions directly and line by line, without the need for prior compilation into machine language (binary). Instead of converting the entire program into machine code at once, as compiled languages do, they interpret and execute each instruction on the fly.
Examples are Python, JavaScript or Bash
Mostly easier to write than compiled code. Modern computers = fast so the executable time is less relevant. Important part is time taken to write the code
What are compilers and compiling languages?
Compilers are software tools that converts a program’s source code into machine code and saves it in an executable file that can be loaded and run directly by the computer chip.
A compiled language in terms of programming is a language where the source code is translated into machine code, or binary code, by a compiler before it is executed. This translation process produces an executable file that the computer’s processor can run directly, without the need for an interpreter at runtime.
Traditionally executable files run faster than interpreted code.
What are SPECIFICATIONS (in sofware development)?
Specifications are detailed documents that describes what a program (script, component, module or entire systems) should do. Can be written in natural or formal language. Might include examples.
What is a COMMENT?
A comment is text within a program that provides information about the code. It’s marked by delimiting punctuation and is ignored by the python interpreter. Format is not specified.
Two types. A BLOCK comment and a LINE comment
What is a BLOCK comment?
A comment over multiple lines. Begins and ends with three consequetive quotation marks. Typically it is a long explanation about the next bit of code.
e.g. a good example of a header block comment is:
“””
File: hello.py
Description: Says hello
Author: Chris Bleakley
Date: 04/02/2025
Version: 1.0
“””
What is a LINE comment?
A short comment over one line only. Begins with the hash symbol. Often introduces the next few lines or clarifies something at the end. Consequetive line comments can be used (like a block comment)
What is an f string?
An f string is a FORMATTED STRING literal.
It allows you to embed expressions inside string literals, using curly brackets {}. i.e the curly brackets are used to delimit a variable whose content will be displayed. This makes it easier and more readable to format strings. The variable can be of any data type, can be formatted or can be replaced by an expression
What is the recommended maximum line length in Python?
The recommended maximum line length in Python is 79
characters.
What are programmers two goals?
Programmers have two goals:
1. Their code works (meets the specifications)
2. Their code is readable
Programmers spend 60-80% of their time reading code.
Always write code that is easy to read.