Skip to content

Commit

Permalink
update to python 3.11 (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
januschung committed Jul 26, 2023
1 parent 11aa6b2 commit 18761e6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
- name: Set up Python 3.11
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: 3.11
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ There are five choices:
5. Mixed

## Requirements
[python3](https://www.python.org/downloads/)
[python3.11](https://www.python.org/downloads/)

Install required package with the following command:
```
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
fpdf==1.7.2
fpdf2==2.7.4
12 changes: 8 additions & 4 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import argparse
import random
from fpdf import FPDF
from fpdf.enums import XPos, YPos
from functools import reduce
from typing import List, Tuple

Expand All @@ -31,7 +32,7 @@ def __init__(self, type_: str, max_number: int, question_count: int):
self.num_x_cell = 4
self.num_y_cell = 2
self.font_1 = 'Times'
self.font_2 = 'Arial'
self.font_2 = 'Helvetica'

# From https://stackoverflow.com/questions/6800193/what-is-the-most-efficient-way-of-finding-all-the-factors-of-a
# -number-in-python
Expand All @@ -46,7 +47,8 @@ def division_helper(self, num) -> [int, int, int]:
num = random.randint(0, self.max_number)
# pick a factor of num; answer will always be an integer
if num:
factor = random.sample(self.factors(num), 1)[0]
# factor = random.sample(self.factors(num), 1)[0]
factor = random.sample(list(self.factors(num)), 1)[0]
answer = int(num / factor)
return [num, factor, answer]

Expand Down Expand Up @@ -218,8 +220,10 @@ def make_answer_page(self, data):
"""Print answer sheet"""
self.pdf.add_page(orientation='L')
self.pdf.set_font(self.font_1, size=self.large_font_size)
self.pdf.cell(self.large_pad_size, self.large_pad_size, txt='Answers', ln=1, align='C')

self.pdf.cell(self.large_pad_size, self.large_pad_size, txt='Answers', new_x=XPos.LEFT, new_y=YPos.NEXT, align='C')
# new_x=XPos.RIGHT, new_y=YPos.TOP
# new_x=XPos.LEFT, new_y=YPos.TOP
# new_x=XPos.LEFT, new_y=YPos.LAST
for i in range(len(data)):
self.pdf.set_font(self.font_1, size=self.small_font_size)
self.pdf.cell(self.pad_size, self.pad_size, txt=f'{i + 1}:', border='TLB', align='R')
Expand Down

0 comments on commit 18761e6

Please sign in to comment.