Source Code
![]() | This page is incomplete. |
Source Code | |
---|---|
Type | Inquiry |
Category | Lab |
Source Code is a Division B and Division C event that was first run as a trial at the 2016 Michigan state tournament. It has been run in Michigan every year since, and was also run at the 2018 Texas state tournament. Competitors are asked to develop and code computer programs to solve a given problem. This event is similar to Code Analysis, an event commonly run in Wisconsin as a pilot event.
The Event
Competitors are provided with a computer without internet access for the duration of the event. The programming language used for the event is Python (version 3.4.3 or newer). Teams are also allowed to bring a 3"x5" note card with notes on both sides for reference.
Python Syntax
Data Types and Functions
When declaring a variable, the data type does not have to be given. As the program is analyzed, the data type is assumed based on what is put into the variable. Python uses the following data types the majority of the times: int, double, float, char, bool. However, other data types exist such as list, dict, str, and set, which are used more in conjunction with other data types. If one wants to find the data type of a variable, one can use the type() function.
When declaring a function, one first puts def at the beginning, then the function name, then the parameters that the function takes when using it. A colon is at the end of the function header and then in the body contains the code needed to make the function work. At the end of the function comes return, which tells the function what value to return.
Installing the IDE
In order to practice coding with Python at home, students will have to install an Integrated Development Environment, or IDE. This allows students to create and run programs in one complete package. Be sure to install the proper version of Python, since some commands that appear in Python 3 will not be compatible with Python 2.
Windows
Most Windows computers do not come with Python preinstalled, though it may be worthwhile to check in the list of programs installed on the target computer and see if it is. If the version of Python is lower than 3.4.3, uninstall it and download the newest version to ensure that any practice code will work at the event. Downloading and installing Python for Windows is as simple as navigating to the official Python website and clicking on the latest Python 3 release. The downloadable files are at the bottom of the page under the "Files" heading. If the target computer has a 64 bit processor, download the x86-64 executable installer. If the computer only has an 32 bit (x86) processor or it is unclear if the processor is 32 bit or 64 bit, download the x86 executable installer. Double-click the program once it is downloaded, and follow the instructions in the installer.
macOS
While some versions of macOS may include different versions of Python, it likely will not be the version of Python used in the event. Uninstall any outdated version of Python currently on the target computer to ensure that any code created away from the event could be used at the competition. Installing Python for macOS is very similar to installing it on a Windows computer. Navigate to the official Python website and click on the latest Python 3 release. The downloadable files are located at the bottom of the page underneath the "Files" heading. If the target computer is running Mac OS X 10.6 Snow Leopard or above, then download the macOS 64-bit/32-bit installer. If the target computer is running OS X 10.9 Mavericks or above, then download the macOS 64-bit installer. Once the installer is downloaded, double-click the program and follow the instructions in the installer.
Scoring
The highest event score wins. Each answer that returns the correct output will receive full points. Each problem is worth a minimum of 2 points, and the score of each problem is determined at the event. Problems requiring more elaborate solutions will be worth more points. Bonus objectives may also be given, and extra points will be given for any team that achieves these. Attempted problems with incorrect outputs are worth one point and programs that do not run can receive a maximum of one point. Using other electronic devices will disqualify the team. Ties will be broken by a designated tiebreaker problem, and if there is still a tie then the team with the highest number of correct problems will win.