Computer Science 340
Programming Languages
Fall 2023, Siena College
This lab is a continuation of the last, continuing your exploration of some of the features of the Python programming language, focusing on things that it does differently from Java.
This is an individual lab, but you are welcome to collaborate with classmates as you work through. However, the work you submit must ultimately be your own, and you are responsible for understanding everything in the lab.
Learning goals:
Getting Set Up
In Canvas, you will find a link to follow to set up your GitHub repository, which will be named python2-lab-yourgitname, for this lab.
First, A Little Math
In the first Python lab, we saw that some functions are always available to all Python programs, like print and input. This can be thought of as being analogous to Java's implicit import of the classes in the java.lang package. When a Python program needs to use other functions, one or more modules will need to be imported.
For example, to use the mathematical functions in the math module, a program should include the statement:
import math
The Connections Game asks players to take a group of 16 words and put them into 4 groups of 4, where each group is "connected" by a common theme. One can take a group of 16 items and form
(16 choose 4) * (12 choose 4) * (8 choose 4) * (4 choose 4)x
different groupings.
Unlike in Java, Python programmers do not need to worry about exceeding the capacity of their integer datatypes.
Functions
You read as part of the previous lab about text and lists in Python. Now read Section 4.7 of the Python Tutorial about defining functions.
Classes
Section 9 of the Python Tutorial describes how classes work in Python.
Your repository contains a Java implementation of a Ratio class and some tests in the main method of the Ratios class. Many of you have probably seen this code before.
Submission
Commit and push!
Grading
This assignment will be graded out of 50 points.
Feature | Value | Score |
conn.py | 5 | |
Factorial.java | 5 | |
factorial.py | 5 | |
func.py | 10 | |
func2.py | 5 | |
ratio.py | 20 | |
Total | 50 | |