Make a directory as Q1
, change your working directory in it. Write a shell script named shell1.sh
. Create 3 folders and a file in it. Src
, Docs
, Data
and README.md
.
#!/bin/sh
# Author : Ogrenci Adi
# Date : 10-24-07---10-11-2024
# Last Modified : 10-24-32---10-11-2024
mkdir Src Docs Data
touch README.md
Make a directory as Q2
, change your working directory in it. Write a shell script named shell2.sh
. Create 4 folders and 2 files in this shell script. Data
, Output
, Scripts
, Backup
, README.md
and evaluateMyExam.sh
.
Make a directory as Q3
, change your working directory in it. Write a shell script named shell3.sh
creating the folders and files as shown below.
Q3
├── data
│ └── README.md
├── docs
│ └── README.md
├── README.md
└── src
└── README.md
Make a directory as Q4
, change your working directory in it. Write a shell script named shell4.sh
creating the folders and files as shown below.
Q4
├── codes
│ └── calculate.py
├── files
│ └── lists.txt
├── README.md
└── results
└── results.txt
Make a directory as Q5
, change your working directory in it. Write a shell script named shell5.sh
creating 3 folders named as 1
, 2
and 3
and creating 100 files in each folder (totally 300 files) named as 001.txt
, 002.txt
, ..., 100.txt
and writing the file name in it as This is file 1 in folder 1.
, This is file 2 in folder 3.
, ..., This is file 100 in folder 2.
for example.
Make a directory as Q6
, change your working directory in it.
Write a shell script named shell6.sh
creating 100 files named as 001.txt
, 002.txt
, ..., 100.txt
and writing whether the file number is odd or even in the file. For example, This is an odd number.
for file001.txt
and This is an even number.
for file100.txt
.
Make a directory as Q7
, change your working directory in it.
Write a shell script named shell7.sh
printing Hello Nicola Tesla.
when it is run as ./shell7.sh Nicola Tesla
. Use your own name to check if it works for any names.
Make a directory as Q8
, change your working directory in it.
Write a shell script named shell8.sh
creating file.txt
with a content of This file is made by shell8.sh file.
. Then change its content using sed
command to This file is changed by shell8.sh file.
.
Make a directory as Q9
, change your working directory in it.
Write a shell script named shell9.sh
. In this script, check if the Data
directory exists.
If it does, print Data directory already exists.
.
If it doesn’t, create the Data
directory and print Data directory created.
.
Make a directory as Q20, change your working directory in it.
Write a shell script named shell20.sh that calculates and prints the sum of all even numbers between given 2 numbers.
The script must work with ./shell10.sh 1 100
and prints The sum of even numbers from 1 to 100 is 2550.
.
Make a directory as
Q11
,
change your working directory in it.
Write a Python script named as ageCalculator.py
and calculating users age from his/her birth year.
Read the year information from the commmandline. Use input()
function for it.
Make a directory as
Q12
,
change your working directory in it.
Write a Python script named as calculator.py
and working as a calculator.
Use argparse
module to read numbers and mathematical operation from the commandline as
python3 calculator.py multiplication 2 3
printing 6
, python3 calculator.py addition 2 3
printing 5
, python3 calculator.py division 2 3
printing 0.667
, python3 calculator.py subtraction 2 3
printing -1
.Make a directory as
Q13
,
change your working directory in it.
Write a Python script named as temperatureConverter.py
converting temperature from Celcius to Fahrenheit (e.g. $(10^oC \times 9/5)+32=50^oF$).
Use input()
function to read the temperature value in Celcius.
Make a directory as
Q14
,
change your working directory in it.
Write a Python script named as calculateAverage.py
taking 3 numbers from user with argparse
module and prints the average of these three numbers.
Usage must be python3 calculateAverage.py -f 5 -s 10 -t 15
and the result must be Average of 5, 10 and 15 is 10.
.
Make a directory as
Q15
,
change your working directory in it.
Write a Python script named as factorialCalculator.py
taking a number from user with argparse
module and prints the factorial of the number.
You can download an example midterm exam by clicking here