Skip to content

Instantly share code, notes, and snippets.

View thaopham31241027486-coder's full-sized avatar

thaopham31241027486-coder

  • Joined Aug 19, 2025
View GitHub Profile
@thaopham31241027486-coder
thaopham31241027486-coder / baitap5.py
Created September 10, 2025 15:56
baitap5 baitap5
def bai1():
print("Bài 1: Viết hàm Python tìm số lớn nhất trong 3 số")
a = float(input("Nhập số thứ nhất: "))
b = float(input("Nhập số thứ hai: "))
c = float(input("Nhập số thứ ba: "))
print("Số lớn nhất là:", max(a, b, c))
def bai2():
print("Bài 2: Viết hàm Python tính tổng tất cả các số trong danh sách")
@thaopham31241027486-coder
thaopham31241027486-coder / baitap4.py
Created September 10, 2025 15:41
baitap4 baitap4
# a) Convert two lists into a dictionary
print('a.')
keys = ["id", "name", "age"]
values = [101, "Alice", 20]
my_dict = dict(zip(keys, values))
print("Converted dictionary:", my_dict)
# b) Merge two dictionaries
print('b.')
dict1 = {"a": 1, "b": 2}
# 1. Write a Python program to sum all the items in a list.
def bai1():
print("B1: Tổng phần tử ")
def sum_list(i):
sum_numbers = 0
for x in i:
sum_numbers += x
return sum_numbers
b1 = input("Nhập các số (cách nhau bởi dấu cách): ")
i = [int(x) for x in b1.split()]
#1.Guess The Number
import random
money = 100
win = 0
lose = 0
print("1. Guess The Number")
while money >= 5:
print(f"Bạn hiện có {money}$")
while True:
#1.Guess The Number
import random
money = 100
win = 0
lose = 0
print("1. Guess The Number")
while money >= 5:
print(f"Bạn hiện có {money}$")
while True:
#Bai 1 Write a Python program to calculate the length of a string.
def bai1():
print('Bai 1: Tính độ dài của một chuỗi')
def string_length(s):
return len(s)
user_input = input("Enter a string: ")
length = string_length(user_input)
print(f"String: {user_input}")
print(f"The length of the string is: {length}")