-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfinalPrep.py
More file actions
107 lines (84 loc) · 2.85 KB
/
Copy pathfinalPrep.py
File metadata and controls
107 lines (84 loc) · 2.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# name:str = input(str("Enter your name: "))
# print(name)
bookCount:int= 0
totalPages:int = 0
def displayBanner():
print("LIBRARY CATALOG")
def initLibrary():
global bookCount
bookCount = 0
def getLibrarianName():
librarianName:str = input(str("Please enter your name"))
while len(librarianName) < 2:
print("invalid name, must be two characters")
librarianName:str = input(str("Please enter your name"))
return librarianName
def getValidInt(prompt, low, high):
prompt = int(prompt)
while prompt < low or prompt > high:
print("That is an invalid year")
prompt:str=input(str("Enter Publication year: "))
prompt = int(prompt)
def getValidPageCount():
pageCount:int = int(input("Please enter the page count: "))
while pageCount <= 0 or pageCount >= 2000:
print("Invalid page count")
pageCount = int(input("Please enter the page count: "))
return pageCount
# def formatTitle(title:str):
# newTitle:str
# print("newTitle is now " + title)
# counter:int = 0
# while counter<len(title):
# print("counter = " + str(counter))
# if counter == 0:
# newTitle[0] = title[0].upper()
# else:
# newTitle[counter]= title[counter]
# counter = counter + 1
# return newTitle
def formatTitle(title:str):
i:int = 1
newTitle:str = title[0].upper()
while i < len(title):
newTitle= newTitle + title[i]
i = i+1
print("the proper format is " + str(newTitle))
def analyzeTitle(title:str):
uppercase: int = 0
lowercase: int = 0
count = 0
while count < len(title):
if title[count].isupper():
uppercase = uppercase + 1
if title[count].islower():
lowercase = lowercase + 1
count = count + 1
print("there are " + str(uppercase) + " upper, and " + str(lowercase) + " lower.")
def catalogBook(title:str, pages:int):
global bookCount
bookCount = bookCount + 1
global totalPages
totalPages = totalPages + pages
def displayLibrarySummary():
print("total pages: " + str(totalPages))
print("total Book Count: " + str(bookCount))
def main():
displayBanner()
initLibrary()
libName:str = getLibrarianName()
print("Hello, " + libName.upper())
while bookCount<4:
print("Current book number: " + str(bookCount))
title:str = input(str("Please enter the title: "))
print("the title is " + str(title))
formattedTitle:str =formatTitle(title)
analyzeTitle(title)
getValidInt(int(input("Enter publication year")), 1900, 2026)
pages:int =getValidPageCount()
catalogBook(formattedTitle, pages)
response:str = input("catalog anbother book?" )
if (response.lower() != "yes"):
break
displayLibrarySummary()
main()