[go: up one dir, main page]

0% found this document useful (0 votes)
28 views5 pages

Coding Tournament - Level 3

The document provides instructions for students to submit code for a coding tournament. It details how to create and name a Python file with their ID number to submit functions that are provided as exercises. The exercises include writing functions to check if a number is negative, process pandas DataFrames for a trading strategy, check properties of a list, test an integer against mathematical conditions, find the longest string in a list, and determine if a list is monotonically increasing, decreasing, or not monotonic. Students are instructed to only include the function code and import any necessary libraries in their Python files submitted on Moodle.

Uploaded by

Stanislav Dimov
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views5 pages

Coding Tournament - Level 3

The document provides instructions for students to submit code for a coding tournament. It details how to create and name a Python file with their ID number to submit functions that are provided as exercises. The exercises include writing functions to check if a number is negative, process pandas DataFrames for a trading strategy, check properties of a list, test an integer against mathematical conditions, find the longest string in a list, and determine if a list is monotonically increasing, decreasing, or not monotonic. Students are instructed to only include the function code and import any necessary libraries in their Python files submitted on Moodle.

Uploaded by

Stanislav Dimov
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

CODING

TOURNAMENT
Level 3
]\

DATA-Driven Trading Strategy


Mandatory steps to follow:
1. By the end of next friday, each student should upload on Moodle a
python file with the requested functions;
2. Python filename MUST be "ID_NUMBER.py", for example, 123456.py
3. In your Python file don't write any comment or text. Just your solutions
(functions) to the questions below;
4. Don’t write any print or input/inputs in your code. All the testing
examples will be given by the instructor script;
5. IMPORTANT: Whenever you want to use an external library in your
conde or functions, is mandatory to import them! (Example:)

Import pandas as pd
Import numpy as np
6. Only files following this criteria will be graded.

1st Option: How to Create a Python file (With Python IDE)


1. Create an empty file;
2. save it as "ID_NUMBER.py";
3. Write your code to answer exercise questions;
4. save it as "ID_NUMBER.py";

1
]\

2nd Option: How to Create a Python file (With Notepad or


similar)
1. Create an empty file;
2. save it as "ID_NUMBER.py";
3. Write your code to answer exercise questions;
4. save it as "ID_NUMBER.py";

3rd Option: How to Create a Python file (With Google


Colab)
1. Create a Google Colab Notebook;
2. Rename it to "ID_NUMBER.ipynb";
3. Write your code to answer exercise questions;
4. Go to FILE -> Download -> Download .py

Coding Example
Write a function to check if a number is negative.

FUNCTION NAME: negativeChecker


NUMBER OF INPUTS: 1
NUMBER OF OUTPUTS: 1 (True/False)

What should be in your python file:

def negativeChecker(my_input):
if my_input < 0:
return True
else:
return False

2
]\

Exercise 1
Write the function in Python, called “engine”, that you have used in the
Berkshire Hathaway case study. Basically, a function that reads 3 pandas
DataFrames, and returns a single DataFrame or pandas.Series with the daily
returns of your trading strategy.

FUNCTION NAME: engine


NUMBER OF INPUTS: 3 (DataFrames)
NUMBER OF OUTPUTS: 1 (DataFrame or Pandas.Series)

Exercise 2
Write a Python function to check if the input is a list of integers with exactly
two occurrences of nineteen and at least three occurrences of five.

FUNCTION NAME: listChecker


NUMBER OF INPUTS: 1 (list)
NUMBER OF OUTPUTS: 1 (True or False)

Exercise 3
Write a Python function that accepts an integer, and tests whether the input
integer is greater than 4^4 and if the mod 34 is equal to 4.

3
]\

FUNCTION NAME: powerModule


NUMBER OF INPUTS: 1 (integer)
NUMBER OF OUTPUTS: 1 (True or False)

Exercise 4
Write a Python function to find the longest string of a given list of strings.

FUNCTION NAME: maxLength


NUMBER OF INPUTS: 1 (list)
NUMBER OF OUTPUTS: 1 (string)

Exercise 5
Write a Python function to determine the direction ('increasing' or
'decreasing') of monotonic sequence numbers.
Example:
Input: [1, 2, 3, 4, 5, 6] -> Output: Increasing
Input: [6, 5, 4, 3, 2, 1] -> Output: Decreasing
Input: [19, 19, 5, 5, 5, 5, 5] -> Output: Not Monotonic

FUNCTION NAME: monotonic


NUMBER OF INPUTS: 1 (list)
NUMBER OF OUTPUTS: 1 (string: “Increasing”, “Decreasing” or “Not
Monotonic”)

You might also like