Enter a n, Output the corresponding diamond array
3
*
***
*****
*******
*****
***
*
3
* *** ***** *** *
c=eval(input())
def stars5(n):
RANGE1 = [2*i+1 for i in range(n)]
RANGE2 = [2*i+1 for i in range(n)[::-1]][1:]
RANGE = RANGE1 + RANGE2
RANGE_1 = [i for i in range(n)[::-1]]
RANGE_2 = [i for i in range(n)[1:]]
RANGE_12 = RANGE_1 + RANGE_2
for i in range(len(RANGE)):
print (' '*RANGE_12[i] + '*'*RANGE[i])
if __name__ == "__main__":
stars5(c)This topic requires reading a string , Count the letters in the string 、 Numbers 、 Space 、 The number of other characters .
Enter a line of string consisting of any character .
Count the letters in the string 、 Numbers 、 Space 、 The number of other characters .
2a and Am3,MNak888!..
letters=10,digits=5,spaces=2,others=4
a=input()
isalpha=0
isdigit=0
isspace=0
other=0
for i in a:
if i.isalpha():
isalpha=isalpha+1
elif i.isdigit():
isdigit=isdigit+1
elif i.isspace():
isspace=isspace+1
else:
other=other+1
print("letters={},digits={},spaces={},others={}".format(isalpha,isdigit,isspace,other))This topic requires you to input the password string according to ( String length greater than 6), Output password strength . The rules : Password requirements can only contain capital letters 、 Lowercase letters 、 Numbers and underscores , If only one of them is included , Then the password strength is 1; If two of them are included , Then the password strength is 2; If three of them are included , Then the password strength is 3; If you include four of them , Then the password strength is 4.
The input length is greater than 6 String .
Output password strength .
123456789
1
a=input()
islower=0
isupper=0
isdigit=0
other=0
for i in a:
if i.islower():
islower=1
elif i.isupper():
isupper=1
elif i.isdigit():
isdigit=1
elif i=="_":
other=1
print("{}".format(islower+isupper+isdigit+other))