#
CMU 15-112 Summer 2018: Fundamentals of Programming and Computer Science

Homework 1 (Due Tue 22-May, at 5pm)

- This assignment is SOLO. This means you may not look at other student's code or let other students look at your code for these problems. See the syllabus for details.

- To start:
- Create a folder named 'week1'
- Download
hw1.py
to that folder
- Edit hw1.py using Pyzo
- When you are ready, submit hw1.py to Autolab. For this hw, you may submit up to 20 times
(which is way more than you should require),
but only your last submission counts.

- Do not use string indexing, loops, lists, or recursion in this assignment.
- Do not hardcode the test cases in your solutions.

**isEquilateralTriangle(side1,side2,side3)** [25pts]

Write the function isEquilateralTriangle(side1,side2,side3) that takes three sides to a triangle. The sides will be positive floats/ints. Return True if the 3 sides make up an equilateral triangle. Returns False otherwise. Hint: almostEquals might be helpful here.

**getKthDigit(n, k)** [35pts]

Write the function getKthDigit(n, k) that takes a possibly-negative int n and a non-negative int k, and returns the kth digit of n, starting from
0, counting from the right. So:

getKthDigit(789, 0) returns 9

getKthDigit(789, 2) returns 7

getKthDigit(789, 3) returns 0

getKthDigit(-789, 0) returns 9

Note: There will be a large hint for this problem in recitation on Monday.

**isPerfectSquare(n)** [40pts]

Write the function isPerfectSquare(n) that takes a possibly-non-int value, and returns True if it is an int that is a perfect square (that is, if there exists an integer m such that m**2 == n), and False otherwise. Do not crash on non-ints nor on negative ints.