Last active
April 13, 2018 19:07
-
-
Save toannd96/b171deca937b0958993e52c0ef3bda89 to your computer and use it in GitHub Desktop.
Nop_Bai_Test_Python
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
print('1'+ ' ' +'*') | |
print('2'+ ' ' +'**') | |
print('3'+ ' ' +'***') | |
print('4'+ ' ' +'****') | |
print('5'+ ' ' +'*****') | |
print('6'+ ' ' +'******') | |
print('7'+ ' ' +'*******') | |
print('8'+ ' ' +'********') | |
1 * | |
2 ** | |
3 *** | |
4 **** | |
5 ***** | |
6 ****** | |
7 ******* | |
8 ******** | |
for i in range(1,9): | |
...: print(i,end='\t') | |
...: for j in range(1,1+i): | |
...: print('*',end='') | |
...: print('\n',end='') | |
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
string = 'Viet Nam' | |
result= ' '.join(reversed(list(string))) | |
print(result) | |
#reversed() đảo ngược thứ tự các đối tượng trong list | |
#Nam Viet |
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
str = "Viet Nam Ha Noi Hai Phong Hai Duong" | |
List = list(str.upper()) | |
#Liet ke cac chu cai xuat hien trong List | |
print(List) | |
#Dem so lan cac chu cai xuat hien | |
for word in List: | |
print (word, str.count(word)) | |
['V', 'i', 'e', 't', ' ', 'N', 'a', 'm', ' ', 'H', 'a', ' ', 'N', 'o', 'i', ' ', 'H', 'a', 'i', ' ', 'P', 'h', 'o', 'n', 'g', ' ', 'H', 'a', 'i', ' ', 'D', 'u', 'o', 'n', 'g'] | |
V 1 | |
i 4 | |
e 1 | |
t 1 | |
7 | |
N 2 | |
a 4 | |
m 1 | |
7 | |
H 3 | |
a 4 | |
7 | |
N 2 | |
o 3 | |
i 4 | |
7 | |
H 3 | |
a 4 | |
i 4 | |
7 | |
P 1 | |
h 1 | |
o 3 | |
n 2 | |
g 2 | |
7 | |
H 3 | |
a 4 | |
i 4 | |
7 | |
D 1 | |
u 1 | |
o 3 | |
n 2 | |
g 2 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment