Python's exercises for data academy
Clone this repository
git clone [email protected]:Maclenn77/data-academy-python-lab.git
- Python 3
After cloning the repo,
cd data-academy-python-lab/exercises
python3 activity_NUMBER.py
Some tests had been added at the end of the file to review the results
Objective: Introduce variables, data types, and control flow statements in Python.
- Declare two variables,
num1
andnum2
, and assign them with integer values. - Write a program that checks if
num1
is greater thannum2
and prints the result. - Use an
if-else
statement to determine if the values ofnum1
andnum2
are equal or not, and print an appropriate message. - Prompt the user to enter a number and store it in a variable.
- Use a loop to print all the numbers from 1 to the user-input number.
Objective: Introduce functions and basic file handling operations in Python.
- Write a function that takes two parameters,
num1
andnum2
, and returns their sum. - Create a text file named "numbers.txt" and write a few numbers, each on a new line.
- Write a function that reads the numbers from the file and calculates their average.
- Implement a function that takes a string as input and writes it to the end of the "numbers.txt" file.
- Call the functions and print the results.
Objective: Introduce lists, basic algorithms, and list manipulation in Python.
- Create a list of integers containing at least 10 elements.
- Write a function that takes the list as input and returns the maximum and minimum values.
- Implement a function that reverses the order of the elements in the list.
- Write a function that searches for a given value in the list and returns its index.
- Implement a function that takes a list of numbers and returns a new list with only the even numbers.