-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathexample.py
More file actions
66 lines (42 loc) · 1.5 KB
/
example.py
File metadata and controls
66 lines (42 loc) · 1.5 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
#
# Decription: This program will analize the upper and lower case content of
# a given string.
#
sampleString = ("We the People of the United States, in Order+ to form a more perfect Union,"
" establish Justice, insure domestic Tranquility, provide for the common defence, promote the general Welfare,"
" and secure the Blessings of Liberty to ourselves and our Posterity, do ordain and establish this Constitution"
" for the United States of America.")
# 1) Start by counting the number of upper, lower, and other characters in the provided string. Print your results.
# 2) Next, invert the case of all of the text in the sample string. Print the resulting string.
# 3) Place all vowels in one list.
# 4) Place all consonant in another list.
# 5) Find the decimal value of each character and place all characters that are multiples of 3 in another list.
lowers = 0
uppers = 0
not_letters = 0
vowel_list = []
consonant_list = []
new_string = ""
for char in sampleString:
if char.islower():
new_string += char.upper()
lowers += 1
elif char.isupper():
new_string += char.lower()
uppers += 1
else:
new_string += char
not_letters += 1
if char.lower() in "aeiouy":
vowel_list.append(char)
elif char.isalpha():
consonant_list.append(char)
print(lowers, uppers, not_letters)
print()
print(new_string)
print()
print(vowel_list)
print()
print(consonant_list)
print()
print([ord(c) for c in sampleString if ord(c)%3==0])