In this assignment, you will explore basic Python programming concepts, including arithmetic operations, variable assignments, data types, lists, and user inputs. You will create and run simple Python scripts to apply these concepts and document your results.
Assignment4
.Assignment4
, create the following subfolders:scripts
: for storing your Python scripts.figures
: for storing screenshots of your outputs.documents
: for any additional notes or explanations.scripts
folder, create a Python file named arithmetic_operations.py
.a = 7
b = 3
print(f"{a} + {b} = {a + b}")
print(f"{a} - {b} = {a - b}")
print(f"{a} * {b} = {a * b}")
print(f"{a} / {b} = {a / b}")
print(f"{a} % {b} = {a % b}")
print(f"{a} ** {b} = {a ** b}")
python3 scripts/arithmetic_operations.py
arithmetic_operations.txt
file:python3 scripts/arithmetic_operations.py > documents/arithmetic_operations.txt
screen
command to split your terminal into two panes.arithmetic_operations.py
with vim
.cat
to display the contents of documents/arithmetic_operations.txt
.arithmetic_operations.png
in the figures
folder.scripts
folder, create a Python file named output_to_file.py
.print((2 + 3 * 5) % 7)
print(10 * 2)
print(2 * 10**-4)
output_to_file.txt
:python3 scripts/output_to_file.py > documents/output_to_file.txt
output_to_file.txt
:cat documents/output_to_file.txt
screen
command to split your terminal into two panes.output_to_file.py
with vim
.cat
to display the contents of documents/output_to_file.txt
.output_to_file.png
in the figures
folder.scripts
folder, create a Python file named print_and_input.py
.print
and input
functions. Use the following format:print("Hello World!")
print("This is written in Python.")
user_answer = input("How old are you? ")
print("Okay. You are " + user_answer + " years old.")
python3 scripts/print_and_input.py
When prompted, enter a sample age (e.g., 20
) to see the result.
Take a Screenshot:
screen
command to split your terminal into two panes.print_and_input.py
with vim
.print_and_input.png
in the figures
folder.scripts
folder, create a Python file named data_types.py
.print("Integers")
print(int(2.1))
print("Floats")
print(float(2.1))
print("Strings")
print(str(2.1))
print("Booleans")
print(bool(2 > 3))
python3 scripts/data_types.py
screen
command to split your terminal into two panes.data_types.py
with vim
.cat
.data_types.png
in the figures
folder.scripts
folder, create a Python file named lists_operations.py
.firstList = [2, 3, 5, 7, 11]
print(firstList)
secondList = ['A', 'B', 'C']
print(secondList)
thirdList = [13, 17, 'D', 'E', 19.2, 23.3]
print(thirdList)
print("First item:", firstList[0])
print("Last item:", secondList[-1])
python3 scripts/lists_operations.py
screen
command to split your terminal into two panes.lists_operations.py
with vim
.cat
.lists_operations.png
in the figures
folder.Finally, create a README.md
file in the Assignment4
folder:
vim README.md
In the README.md file, briefly describe what each file and folder is as follows:
# Assignment 4: Introduction to Python Programming
## Objective
This assignment focuses on learning basic Python programming concepts, including arithmetic operations, data types, lists, and user inputs. The project is divided into five tasks, each with scripts and documentation.
There are four components (3 `folders` and 1 `.md` file) here:
1. **`scripts`**
This folder contains 5 Python scripts:
- `arithmetic_operations.py`: Demonstrates basic arithmetic operations.
- `output_to_file.py`: Performs arithmetic operations and redirects output to a file.
- `print_and_input.py`: Showcases the use of `print` and `input` functions.
- `data_types.py`: Illustrates different data types like integers, floats, strings, and booleans.
- `lists_operations.py`: Creates and manipulates lists in Python.
2. **`figures`**
This folder contains screenshots documenting the Python scripts:
- `arithmetic_operations.png`: Shows `arithmetic_operations.py` and its output.
- `output_to_file.png`: Displays `output_to_file.py` and its output file.
- `print_and_input.png`: Shows `print_and_input.py` with sample input/output.
- `data_types.png`: Displays `data_types.py` and its output.
- `lists_operations.png`: Shows `lists_operations.py` and its output.
3. **`documents`**
This folder contains:
- `arithmetic_operations.txt`: Output of `arithmetic_operations.py`.
- `output_to_file.txt`: Output of `output_to_file.py`.
4. **`README.md`**
This `README.md` file provides an overview of the assignment and its components.
Save and exit the README.md
file. (:wq
)
Before running the submitAssignment.sh
file, make sure you are in the "Assignment 4" folder.
Running this script in any other folder or subfolder may result in missing files being uploaded.
When executed in the correct folder, all files in the "Assignment 4" directory will be included in the submission.
submitAssignment.sh