渥太华大学OU-iti1120 Assignment 1课业解析

这是一份渥太华大学OU-iti1120课程的编程作业,涉及Python编程。作业包括14个编程问题,要求学生设计并实现一系列函数,如勾股定理判断、单位转换、坐标判断等。每个函数需有文档字符串,并通过指定的测试用例。作业提交包含一个.py文件,包含所有函数,和一个.txt文件,记录测试输出。评分将根据语法正确性和函数功能进行,强调使用Python内置函数和基本概念,不允许使用循环、分支语句等,除非题目明确说明。
摘要由CSDN通过智能技术生成

题意:使用Python编写一些函数

解析:

1)编写一个勾股定理的判断函数,输入两个整数a,b如果存在另一个整数c2=a2+b^2则返回true,否则返回false;

2)编写一个英里/小时转换为公里每小时的函数;

3)输入三个数,xs、ys、side,x,y表示正方形左下角的坐标,side表示正方形的边长,函数的作用是判断一个坐标是否在正方形内部,边界也属于内部;

4)判断一个数字中是否含有数字9,或者能否被9整除,是则返回true,否则返回false;

5)接受三个字符串参数:qu’ote,name,year,然后以此输出一段话;

6)编写一个无参数版本的“5)”中的函数;

7)编写一个石头剪刀布的游戏,输入相同为平局。

涉及知识点:

Python,字符处理

更多可加微信讨论

微信号:tiamo-0620

pdf

ASSIGNMENT 1
Read the instructions below carefully. The instructions must be followed. This assignment is
worth 4% of your grade. The assignment is due on Monday, 30th of September at 8AM. No late
assignments will be accepted.
This is an individual assignment. Please review the Plagiarism and Academic Integrity policy
presented in the first class, i.e. read in detail pages 15-18 of course outline (i.e. slides of
Lecture 1). You can find that file on Brightspace under Lecture 1. While at it, also review
Course Policies on pages 13 and 14.
The goal of this assignment is to learn and practice (via programming) the concepts that we
have learned so far: numbers, algebraic expressions, boolean expressions, strings, operations
on strings, type conversion, variables, use of Python’s builtin functions including input and
output functions, designing your own functions, documenting your own functions via
docstrings, and testing your functions. Before you can start this assignment, you need to know
how to use a (IDLE’s) text editor to edit python modules (i.e. files) as well as how to use
python shell interactively to test your code. If you have no idea how to do these things
watching video of the 3rd lecture, for example, will help. Submit your assignment by the
deadline via Brightspace (as instructed and practiced in the first lab.) You can make multiple
submissions, but only the last submission before the deadline will be graded. What needs to
be submitted is explained next.
The assignment has 14 programming questions (in Section 1 below). Each question asks you to
design one function. Put all these functions (for all the questions below) in ONE file only,
called a1_xxxxxx.py (where xxxxxx is replaced with your student number). Within this file,
a1_xxxxxx.py, separate your answers (i.e. code) to each question with a comment that looks
like this:
###################################################################

Question X

###################################################################
To have an idea on what this file a1_xxxxxx.py should look like, I included with this
assignment a solution to an nonexistent assignment. You can view this mockup solution by
opening the included file called a1_mockup_assignment_solution.py
In addition to a1_xxxxxx.py you must submit a separate file called a1_xxxxxx.txt. What
should be in that file is explained below. Thus for assignment 1 you have to SUBMIT TWO
FILES:
• a1_xxxxxx.py and
• a1_xxxxxx.txt.
as instructed in lab 1. Submit your assignment by the deadline via Brightspace (as instructed
in the first lab.)
Your program must run without syntax errors. In particular, when grading your assignment, TAs
will first open your file a1_xxxxxx.py with IDLE and press Run Module. If pressing Run Module
causes any syntax error, the grade for the whole assignment will be zero.
Furthermore, for each of the functions below, I have provided one or two tests to test your
functions with. For example, you should test question 2 by making function call mh2kh(5) in the
Python shell. To obtain a partial mark your function may not necessarily give the correct
answer on these tests. But if your function gives any kind of python error when run on the
tests provided below, that question will be marked with zero points.
After reading each of these questions once, go to the Section 2: “Testing your code" below
and see what the output of your function should give. In that section, you can find a couple of
function calls and the required results for each question. Studying these example function
calls will help you a lot to understand what each individual question requires, or rather what
its function should do.
To determine your grade, your functions will be tested both with examples provided in
Section 2: “Testing your code” and with some other examples. Thus you too should test your
functions with more example than what I provided in Section 2.
Each function must be documented with docstrings (as will be explained in Lecture 5 on Sept
18). In particular, each function has to have docstrings that specify:

  • type contract

  • description about what the function does (while mentioning parameter names)

  • preconditions, if any
    The purpose of this assignment is to practice concepts that you have seen

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值