Untitled

mail@pastecode.io avatar
unknown
python
2 years ago
3.3 kB
110
Indexable
Never
1. Viet chuong trinh nhap vao ba so a, b, c va in ra so lon nhat trong doan [a, b] chia het cho c
2. Viet chuong trinh nhap vao so n va in ra hinh vuong kich thuoc n theo mau sau. Vi du n = 5
# # # # #
# #   # #
#   #   #
# #   # #
# # # # #
3. Viet chuong trinh nhap vao ba so a, b, c va in ra cac so trong doan [a, b] chia het cho c


# for i in range(3, 10, 2):
# for i in range(9, -1, -1):

# for i in range(9, -1, -2):
# 	print(i, end=" ")

# for i in range(10):
# 	for j in range(i):
# 		print(j, end=" ")
# 	print()

# Cho nhap vao mot so n, in ra tam giac gom cac dau *:
# n = 5
# for r in range(1, n+1):
# 	for c in range(r):
# 		print("*", end="")
# 	print()

# *
# **
# ***
# ****
# *****

# n = 5
# for spaces in range(4, -1, -1):
# 	stars = n - spaces
# 	# print(spaces, stars)
# 	for i in range(spaces):
# 		print(" ", end="")
# 	for i in range(stars):
# 		print("*", end="")
# 	print()

#     *  4 1
#    **  3 2
#   ***  2 3
#  ****  1 4
# *****  0 5

n = 5
stars = 1
for spaces in range(4, -1, -1):
	# stars = 2*(n-spaces) - 1
	# print(spaces, stars)
	for i in range(spaces):
		print(" ", end="")
	for i in range(stars):
		print("*", end="")
	print()
	stars += 2

#     *			4 1
#    ***		3 3
#   *****		2 5
#  *******		1 7
# *********   	0 9




# for(i = 0; i < 10; i++)
# 	printf("%d ", i);


# lst = list(map(int, input("Nhap vao day so: ").split()))

# tong_so_chan, tong_so_le, so_so_chan, so_so_le = 0, 0, 0, 0
# for a in lst:
# 	if a%2 == 0:
# 		tong_so_chan += a
# 		so_so_chan += 1
# 	else:
# 		tong_so_le += a
# 		so_so_le += 1

# if so_so_chan == 0:
# 	print("Khong co so chan nao.")
# else:
# 	print("Trung binh cong cac so chan la:", tong_so_chan/so_so_chan)
# if so_so_le == 0:
# 	print("Khong co so le nao.")
# else:
# 	print("Trung binh cong cac so le la:", tong_so_le/so_so_le)


# lst = [3, 2, 4, 6, 11, 7, 8]
# lst = [2, 2, 4, 6, 12, 10, 8]
# lst = [2, 2, -3, 6, -12, 10, -1]

# lst = input("Nhap vao mot day so: ")
# lst = lst.split()
# lst = map(int, lst)
# lst = list(lst)

# lst = list(map(int, input("Nhap vao mot day so: ").split()))

# kq = 0
# for a in lst:
# 	if a%2 != 0:
# 		if kq == 0:
# 			kq = a
# 		elif a > kq:
# 			kq = a

# # for a in lst:
# # 	if a%2 != 0:
# # 		if a > kq:
# # 			kq = a

# if kq == 0:
# 	print("Khong co so le nao")
# else:
# 	print("So le lon nhat la", kq)



# sum = 0
# for a in lst:
# 	if a%2 == 0:
# 		sum = sum + a
# print(sum)






# for(initialization; condition; changes)
# 	statement(s)

# for(i = 0; i < 10; i++)
# 	sum = sum + i;

# for(i = 0, j = 9; i < j; i++, j--)
# 	s = s + i - j;




# # a = float(input("Nhap vao mot so: "))
# # print(type(a))

# # a = 12
# # b = 13.4
# # c = "hello"

# # print(type(a), type(b), type(c))

# # a = int(input("Nhap so a: "))
# # b = int(input("Nhap so b: "))

# # c = a + b

# # print(c)

# num = int(input("Nhap so n: "))

# if num > 0:
# 	# print(f"{num} la so duong")
# 	print(num, "la so duong")
# elif num == 0:
# 	print(num, "la so 0")
# else:
# 	print(num, "la so am")
# # ====================================
# if num > 0:
# 	print(num, "la so duong")
# else:
# 	if num == 0:
# 		print(num, "la so 0")
# 	else:
# 		print(num, "la so am")
# # ====================================
# if num >= 0:
# 	if num > 0:
# 		print(num, "la so duong")
# 	else:
# 		print(num, "la so 0")
# else:
# 	print(num, "la so am")