Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Added homework.
- Loading branch information
Sergiu Harjau
committed
Jan 25, 2019
1 parent
9be8313
commit 400fd3499cfb30a02ed1e7b15e90a041e3311f0d
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
def scanID(studentID): | ||
"""Takes as input a student ID, returns desired digit""" | ||
desiredDigits = ["3", "4", "5", "6"] | ||
for digit in str(studentID): | ||
if digit in desiredDigits: | ||
return (int(digit)) | ||
return 3 | ||
|
||
def receiveInput(): | ||
"""Returns name, sid string tuple""" | ||
name = input("Name? ") | ||
sid = input("StudentID? ") | ||
|
||
return name, sid | ||
|
||
def createOutput(name, sid): | ||
|
||
size = scanID(sid) | ||
i = 1 | ||
name = name.replace(" ", "+") | ||
|
||
for letter in name: | ||
print(letter, end = " ") | ||
if i % size == 0: | ||
print() | ||
i += 1 | ||
|
||
while (i-1) % size != 0: | ||
print("*", end = " ") | ||
i += 1 | ||
|
||
print() | ||
|
||
|
||
if __name__ == "__main__": | ||
name, sid = receiveInput() | ||
createOutput(name, sid) | ||
createOutput(name[::-1], sid) |