Assignment 1
.pdf
keyboard_arrow_up
School
University of Calgary *
*We aren’t endorsed by this school
Course
231
Subject
Computer Science
Date
Jan 9, 2024
Type
Pages
5
Uploaded by CoachNewtMaster80
Copyright ©
2023. Do not distribute outside of the CPSC 231 Fall 2023 class.
CPSC 231 Assignment 1
Eligibility Checker for Alberta Voters
Weight: 3% of final grade
Due date: Friday September 29, at 11:59pm Mountain Time
Submission
:
one Python .py file, submit on the D2L Dropbox. You may submit as many times as
you wish, and only the latest submission will be graded.
Extensions
: You may use your personal days to extend the deadline. An extension request must
be submitted using the request form:
https://forms.office.com/r/2wN7KNhYEK
You have a total of 5 personal days for the entire semester. No penalties for using personal days.
An assignment will not be accepted if it is late and all personal days are already used, other than
in exceptional circumstances.
Academic Integrity
: This work must be completed individually. Please follow academic integrity
rules as discussed during lecture. You may discuss your ideas in English (not in Python) with
other students as much as you like, but make sure that when you write your code that it is your
own. A good rule of thumb is to never share your code with anyone, except your instructor and
TAs.
Detailed Descriptions
As a resident of Alberta, you can be granted many rights and privileges. However, these rights
and privileges often have conditions attached, and a person must meet the stated conditions. In
this assignment, you will write a program that checks the eligibility to vote in Alberta elections.
Step 1:
Create a new Python file to work on.
Step 2:
Your file should start with
from datetime import datetime
month = datetime.now().month
day = datetime.now().day
year = datetime.now().year
Copyright ©
2023. Do not distribute outside of the CPSC 231 Fall 2023 class.
These three variables,
month
,
day
, and
year
, give you the current month, day, and year that you
can use later.
You are only allowed to import datetime as shown above. You are asked to demonstrate
programming at the basic level, so you are not allowed to import anything else.
Step 3:
Create the following behaviour for your program:
Your program should start by asking:
"Are you a Canadian citizen?"
The user can enter "yes" or "no".
"Are you a resident of Alberta?"
The user can enter "yes" or "no".
"What is the month of your birth date?"
The user can enter a month as a number, such as 12.
"What is the day of your birth date?"
The user can enter a day as a number, such as 31.
"What is the year of your birth date?"
The user can enter a year, such as 1990.
Step 4:
After the user enters all the information above, the program should then check for invalid
responses, following the order listed below.
Do not check for invalid responses until after the
user enters all the information.
For the citizen question, if the user's response is anything other than "yes" or "no", output
"Invalid response to citizenship." and exit right away.
Copyright ©
2023. Do not distribute outside of the CPSC 231 Fall 2023 class.
For the resident question, if the user enters anything other than "yes" or "no", output "Invalid
response to residency." and exit right away.
For the month question, if the user enters anything other than an integer between 1 and 12,
output "Invalid month." and exit right away.
For the day question, if the user enters anything other than an integer between 1 and 31, output
"Invalid day." and exit right away.
For the year question, if the user enters anything other than an integer between 1900 and 2023,
output "Invalid year." and exit right away.
Step 5:
After the program passes the checks above, check to see the birth date is indeed valid.
For
example, November 31
st
would be an invalid day since November only has 30 days.
Also, a birth
date in the future is not valid.
The one tricky part is February 29
th
.
You'll need to check to see if the year is a leap year.
If the birth date is not valid, output "Invalid birth date." and exit right away.
Step 6:
If the user is less than 18 years old, they are not eligible to vote.
If the user answered "no" to Canadian citizen or "no" to resident of Alberta, they are not eligible
to vote.
If the user is 18 years old or older, and is a Canadian citizen and an Alberta resident, they are
eligible to vote.
Output either "You are eligible to vote." or "You are not eligible to vote." and exit.
Test cases
How do you know your program is correct?
Your program will be tested on some test cases
using an AI auto-grader. The result will determine your grade on the assignment. To help you fix
your problems, the auto-grader is provided to you, so you can test your code yourself before
you submit.
Be sure to do this to make sure your code runs correctly and there are no typos.
To test your code on the test cases:
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
Submission guidelines: The assignment must be submitted by the deadline (earlier submissions are
encouraged) in PDF format through Blackboard using the following file name format:
LastName_FirstName_Assignment_1.pdf. The assignment must be typewritten.
All the assignments in this course are individual work; any overlap between assignment reports will be
penalized.
A bank requires for their customers to access their online banking accounts to provide as
User Id (or user name) the last 8 digits of their bank card number, and a password with a
length between 8 and 12 ASCII characters, including the following restrictions (posted on
their website):
Passwords must have at least 8 characters long and at most 12 characters long, and must include at least
one character from each of the following four character types:
Upper case letters ABC DEF
Lower case letters ghijkl
Numbers 1 2 345 67890
Special characters ! @ # $ % ^ & * (+) = -
The remaining characters of the password must be selected…
arrow_forward
Written Assignment #1: To submit your assignment, click on the Written Assignment #1 link above. This will take you to
a Preview Upload Assignment window. You'll need to scroll down to Assignment Submission. From here you can write a text
submission or select Browse My Computer and find your file.
Directions: Answer each of the following questions. Show your work or explain how you arrived at your conclusion whenever
appropriate. Use your calculator.
In a random sample of 175 community college students, the mean number of hours spent studying per week is 13.7 hours and
the standard deviation is 4 hours.
a) Find the standard score (z-score) for students who study the following hours in a particular week. Round Z to the nearest
hundredth and interpret the meaning of each answer as it pertains to this problem.
i) 22 hours
ii) 6 hours
b)Assuming the distribution of the number of hours community college students study per week is normally distributed,
approximately how many of the students…
arrow_forward
Move the appropriate file types from the list on the left to the correct descriptions on the right.
File Types (Icons)
XE
F
E
4
Answer Area
A file where you create the user interface
allowing you to display information and react to
user input.
A file that contains all the setup information for
your app.
A file that contains coded app logic.
A file that contains a list of available resources
to be used in the project.
arrow_forward
16.
arrow_forward
Written Use Case
Follow the sample format shown in the attached photo.Sample have its label, while the one you should make a written use case is the one who have blue ovalsNOTE: YOU SHOULD MAKE THE WRITTEN USE CASE AS YOU CAN SEE IN THE SAMPLE TABLE. SOMEONE IS ANSWERING MY QUESTION WRONG!
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:9780357392676
Author:FREUND, Steven
Publisher:CENGAGE L
Related Questions
- Submission guidelines: The assignment must be submitted by the deadline (earlier submissions are encouraged) in PDF format through Blackboard using the following file name format: LastName_FirstName_Assignment_1.pdf. The assignment must be typewritten. All the assignments in this course are individual work; any overlap between assignment reports will be penalized. A bank requires for their customers to access their online banking accounts to provide as User Id (or user name) the last 8 digits of their bank card number, and a password with a length between 8 and 12 ASCII characters, including the following restrictions (posted on their website): Passwords must have at least 8 characters long and at most 12 characters long, and must include at least one character from each of the following four character types: Upper case letters ABC DEF Lower case letters ghijkl Numbers 1 2 345 67890 Special characters ! @ # $ % ^ & * (+) = - The remaining characters of the password must be selected…arrow_forwardWritten Assignment #1: To submit your assignment, click on the Written Assignment #1 link above. This will take you to a Preview Upload Assignment window. You'll need to scroll down to Assignment Submission. From here you can write a text submission or select Browse My Computer and find your file. Directions: Answer each of the following questions. Show your work or explain how you arrived at your conclusion whenever appropriate. Use your calculator. In a random sample of 175 community college students, the mean number of hours spent studying per week is 13.7 hours and the standard deviation is 4 hours. a) Find the standard score (z-score) for students who study the following hours in a particular week. Round Z to the nearest hundredth and interpret the meaning of each answer as it pertains to this problem. i) 22 hours ii) 6 hours b)Assuming the distribution of the number of hours community college students study per week is normally distributed, approximately how many of the students…arrow_forwardMove the appropriate file types from the list on the left to the correct descriptions on the right. File Types (Icons) XE F E 4 Answer Area A file where you create the user interface allowing you to display information and react to user input. A file that contains all the setup information for your app. A file that contains coded app logic. A file that contains a list of available resources to be used in the project.arrow_forward
- 16.arrow_forwardWritten Use Case Follow the sample format shown in the attached photo.Sample have its label, while the one you should make a written use case is the one who have blue ovalsNOTE: YOU SHOULD MAKE THE WRITTEN USE CASE AS YOU CAN SEE IN THE SAMPLE TABLE. SOMEONE IS ANSWERING MY QUESTION WRONG!arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- COMPREHENSIVE MICROSOFT OFFICE 365 EXCEComputer ScienceISBN:9780357392676Author:FREUND, StevenPublisher:CENGAGE L
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:9780357392676
Author:FREUND, Steven
Publisher:CENGAGE L