-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex004.py
More file actions
37 lines (33 loc) · 925 Bytes
/
ex004.py
File metadata and controls
37 lines (33 loc) · 925 Bytes
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
# Exercício 004 - Python/Mundo 1
# Faça um programa que leia algo pelo teclado e mostre na tela o seu tipo primitivo e todas as informações possíveis sobre ele.
print('Exercício 004 - Python/Mundo 1')
expr = input('Digite algo: ')
msg = ''
exp = list(expr)
print('\nA expressão possui {} caracteres: {}'.format(len(expr), exp))
num = 0
spc = 0
m = 0
M = 0
for x in exp:
if x.isnumeric():
num = num + 1
if x.isspace():
spc = spc + 1
if x.islower():
m = m + 1
if x.isupper():
M = M + 1
msg = ''
if num > 0:
msg = msg + str(num) + ' número(s), '
if spc > 0:
msg = msg + str(spc) + ' espaço(s), '
if m > 0:
msg = msg +str(m) + ' letra(s) minúscula(s), '
if M > 0:
msg = msg + str(M) + ' letra(s) maiúscula(s), '
cesp = len(expr) - (num + spc + m + M)
if cesp > 0:
msg = msg + str(cesp) + ' caracter(es) especial(is)'
print('\nEntre eles: ', msg)