Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Write a program that asks the user to enter three numbers and finds the maximum among them:

Viết một
chương trình yêu cầu người dùng nhập ba số và tìm số lớn nhất trong số đó.
Write a program that takes three numbers as input and determines the largest and smallest numbers among
them: Viết một chương trình yêu cầu người dùng nhập ba số và xác định số lớn nhất và nhỏ nhất trong số
đó.
Write a program that takes a year as input and determines if it is a leap year(male) or not: Viết một chương
trình yêu cầu người dùng nhập một năm và xác định xem nó có phải là năm nhuận hay không.
Write a program that asks the user to enter their age and gender, and basedon the input, determine if they
are eligible for retirement benefits. For males, retirement age is 65, and for females, it is 60: Viết một
chương trình yêu cầu người dùng nhập tuổi và giới tính, sau đó dựa trên đầu vào, xác định xem họ có đủ
điều kiện để nhận quyền lợi hưu trí không. Đối với nam giới, tuổi nghỉ hưu là 65, và đối với phụ nữ là 60.
Write a program that asks the user to enter a number and checks if it is apalindrome (will cause the origin
to fall). A palindrome is a number remains the same when its digits are reversed: Viết một chương trình
yêu cầu người dùng nhập một số và kiểm tra xem nó có phải là số đối xứng không. Một số đối xứng là số
mà giữ nguyên giá trị khi các chữ số của nó được đảo ngược.
Prints all even numbers between 1 and N and calculates their sum: In tất cả các số chẵn từ 1 đến N và tính
tổng của chúng
Write a program to find the sum of all numbers divisible by 3 or 5 between 1 and N: Tính tổng của tất cả
các số chia hết cho 3 hoặc 5 từ 1 đến N
Write a program to find the largest element in a given list of numbers: Tìm phần tử lớn nhất trong một danh
sách số được cho trước
Mwrite a program to calculate the sum of all digits in a given number: Tính tổng của tất cả các chữ số
trong một số được cho trước
Write a program to find the factorial (giai thtra) of a given number: Tính giai thừa của một số được cho
trước
Write a program to check if a given number is prime (số nguyên tố): Chương trình kiểm tra xem một số
đã nhập có phải là số nguyên tố hay không.
Write a program to find the reverse of a given number: Chương trình tìm số đảo ngược của một số đã được
nhập.
Write a program that asks the user to enter a password. Keep asking for the password until the user enters
the correct password “20CDT“: Chương trình yêu cầu người dùng nhập mật khẩu và tiếp tục yêu cầu cho
đến khi người dùng nhập đúng mật khẩu “20CDT“
Write a program that prints the sum of all even numbers from 1 to 100: Chương trình tính tổng của tất cả
các số chẵn từ 1 đến 100
Write a program that asks the user to enter a positive integer and calculates its factorial: Chương trình yêu
cầu người dùng nhập một số nguyên dương và tính giai thừa của nó
Write a program that asks the user to enter a number and checks if itis a prime number: Chương trình yêu
cầu người dùng nhập một số và kiểm tra xem nó có phải là số nguyên tố hay không
Write a program that asks the user to enter a series of numbers and calculates their average. The user can
stop entering numbers by entering -1.: Chương trình yêu cầu người dùng nhập một chuỗi số và tính trung
bình của chúng. Người dùng có thể dừng việc nhập số bằng cách nhập -1
Write a program that asks the user to enter a series of numbers and finds the largest number. The user can
stop entering numbers by entering 0: Chương trình yêu cầu người dùng nhập một chuỗi số và tìm số lớn
nhất. Người dùng có thể dừng việc nhập số bằng cách nhập 0
Write a program that generates and prints the multiplication table (bảng cửu chương) for numbers from 5
to 9: Chương trình tạo và in bảng nhân từ 5 đến 9
Write a program that asks the user to enter a series of numbers and finds the sum of numbers divisible by
3. The user can stop entering numbers by entering 0: Chương trình yêu cầu người dùng nhập một chuỗi số
và tính tổng các số chia hết cho 3. Người dùng có thể dừng việc nhập số bằng cách nhập 0
Write a program that generates and prints a random number between 1 and 100. The program should keep
generating new numbers until it generates a number divisible by 7: Chương trình tạo và in một số ngẫu
nhiên từ 1 đến 100. Chương trình sẽ tiếp tục tạo số mới cho đến khi nó tạo ra một số chia hết cho 7
Write a program that calculates the sum of all even numbers between 1 and a given number using a while
loop: Chương trình tính tổng của tất cả các số chẵn từ 1 đến một số được cho trước sử dụng vòng lặp while
Write a function to calculate the area of a rectangle given its length and width: Hàm để tính diện tích của
hình chữ nhật dựa trên chiều dài và chiều rộng:
Write a function to check if a given number is even: Hàm để kiểm tra xem một số cho trước có phải là số
chẵn hay không:
Write a function to calculate the average of a list of numbers: Hàm để tính trung bình của một danh sách
số:
Write a function to find the roots of a quadratic equation (ax*2 + bx +c= 0): Hàm để tìm các nghiệm của
phương trình bậc hai (ax^2 + bx + c = 0):
Write a function called calculate_discounted_price that takes the original price and a discount percentage
as input, and returns the discounted price: Hàm để tính giá giảm giá dựa trên giá gốc và tỷ lệ giảm giá:
Write a function called calculate_power that takes two numbers, base and exponent, as input and returns
the result of base raised to the power of exponent: Hàm để tính lũy thừa của một số dựa trên cơ số và số

Write a function called count_vowels that takes a string as input and returns the number of vowels (a, e, i,
0, u) in the string: Hàm để đếm số nguyên âm trong một chuỗi
Write a function calculate_product that takes a variable number of numeric arguments (integers or floats)
and returns their product: Hàm để tính tích của một số lượng biến (số nguyên hoặc số thực)
Write a function calculate_median that takes a variable number of numeric arguments and returns the
median value: Hàm để tính giá trị trung vị của một số lượng biến đổi của các đối số số học
Write a function find_odd_numbers that takes a variable number of integers as arguments and returns a list
of odd numbers among them: Hàm để tìm các số lẻ trong một số lượng biến đổi của các số nguyên
Write a function calculate_percentage that takes a variable number of numeric arguments representing
values and a total value, and returns the percentage of each value relative to the total: Hàm để tính phần
trăm của một giá trị và tổng giá trị, rồi trả về tỷ lệ phần trăm của mỗi giá trị so với tổng
Using map()
Given a list of strings, capitalize the first letter of each string using map(): Viết hàm chuyển chữ cái đầu
của mỗi chuỗi trong danh sách thành chữ hoa
Given a list of Celsius temperatures, convert them to Fahrenheit using map(): Đưa ra danh sách nhiệt độ độ
C, hãy chuyển đổi chúng thành độ F bằng cách sử dụng map().
Given a list of numbers as strings, convert them to integers using map(): Đưa ra một danh sách các số dưới
dạng chuỗi, hãy chuyển đổi chúng thành số nguyên bằng cách sử dụng map()
Write a lambda function to check ifa number is prime using map(): Viết hàm lambda để kiểm tra xem số
có phải là số nguyên tố hay không bằng cách sử dụng map().
Using filter()
Given a list of numbers, filter out the odd numbers: Cho một danh sách các số, lọc ra các số lẻ.
Given a list of numbers, filter out the numbers that are divisible by 3: Cho một danh sách các số, lọc ra các
số chia hết cho 3
Given a list of strings, filter out the strings with a length greater than 5: Cho một danh sách các chuỗi, lọc
ra các chuỗi có độ dài lớn hơn 5.
Given a list of names, filter out the names that start with the letter "A“: Đưa ra một danh sách các tên, lọc
ra những tên bắt đầu bằng chữ cái "A“
Write a Python program to get the character at a given index ina string: Chương trình Python để lấy ký tự
tại một chỉ số cụ thể trong chuỗi
Write a Python program to geta substring from a given string by slicing: Viết chương trình Python để lấy
một chuỗi con từ một chuỗi đã cho bằng slicing
Write a Python program to reverse a string using slicing: Chương trình Python để đảo ngược một chuỗi
bằng cách sử dụng slicing
Write a Python program to count the occurrences of a specific character in a string: Chương trình Python
để đếm số lần xuất hiện của một ký tự cụ thể trong chuỗi
Write a Python program to replace all occurrences of a specific character in a string: Chương trình Python
để thay thế tất cả các lần xuất hiện của một ký tự cụ thể trong chuỗi
Write a Python program to split a string into a list of words: Chương trình Python để tách một chuỗi thành
một danh sách các từ
Write a Python program to join elements of a list into a string: Chương trình Python để nối các phần tử của
một danh sách thành một chuỗi
Write a Python program to capitalize the first letter of each word in a string: Chương trình Python để viết
hoa chữ cái đầu tiên của mỗi từ trong chuỗi
Write a Python program to checkif a string starts with a specified prefix: Viết chương trình Python để kiểm
tra xem một chuỗi có bắt đầu bằng tiền tố đã chỉ định hay không.
Write a Python program to checkif a string ends with a specified suffix: Viết chương trình Python để kiểm
tra xem một chuỗi có kết thúc bằng hậu tố được chỉ định hay không.
Write a Python program to add a key-value pair to a dictionary: Chương trình Python để thêm một cặp
khóa-giá trị vào từ điển
Write a Python program to access a value in a dictionary using its key: Chương trình Python để truy cập
một giá trị trong từ điển bằng cách sử dụng khóa của nó
Write a Python program to iterate over a dictionary and print its keys and values: Chương trình Python để
lặp lại một từ điển và in ra các khóa và giá trị của chúng
Write a Python program to check if a key exists in a dictionary: Chương trình Python để kiểm tra xem một
khóa có tồn tại trong từ điển hay không
Write a Python program to remove a key-value pair from a dictionary: Chương trình Python để loại bỏ một
cặp khóa-giá trị từ từ điển
Write a Python program to merge two dictionaries: Chương trình Python để hợp nhất hai từ điển:
Write a Python program to find the maximum value in a dictionary: Chương trình Python để tìm giá trị lớn
nhất trong một từ điển
Write a Python program to sort a dictionary by its values in ascending order: Chương trình Python để sắp
xếp một từ điển theo giá trị của nó theo thứ tự tăng dần
Write a Python program to create a dictionary from a list of keys and a single value: Chương trình Python
để tạo một từ điển từ một danh sách các khóa và một giá trị duy nhất
Write a Python program to find the common keys between two dictionaries: Chương trình Python để tìm
các khóa chung giữa hai từ điển
Write a Python function that takes two sets as arguments and returns a new set containing the elements that
are common to both sets: Viết hàm Python lấy hai tập hợp làm đối số và trả về một tập hợp mới chứa các
phần tử chung cho cả hai tập hợp.
Write a Python function that takes a set as an argument and returns a new set containing the unique elements
in the original set in reverse order: Viết hàm Python lấy một tập hợp làm đối số và trả về một tập hợp mới
chứa các phần tử duy nhất trong tập hợp ban đầu theo thứ tự ngược lại
Write a Python function that takes two sets as arguments and returns a new set containing the elements that
are present in the first set but not in the second set: Hàm Python nhận hai tập hợp làm đối số và trả về một
tập hợp mới chứa các phần tử chỉ xuất hiện trong tập hợp thứ nhất nhưng không xuất hiện trong tập hợp
thứ hai
Write a Python function that takes a list of sets as an argument and returns a new set containing the elements
that are present in all sets: Hàm Python nhận một danh sách các tập hợp làm đối số và trả về một tập hợp
mới chứa các phần tử chỉ xuất hiện trong tất cả các tập hợp
Write a Python function that takes two sets as arguments and returns a new set containing the elements that
are exclusive to each set (i.e., present in one set but not in the other): Hàm Python nhận hai tập hợp làm đối
số và trả về một tập hợp mới chứa các phần tử chỉ xuất hiện trong một trong hai tập hợp, không xuất hiện
ở cả hai
Write a Python function that takes a set and a number as arguments and returns a new set containing all
possible subsets of the original set that have a length equal to or less than the given number: Hàm Python
nhận một tập hợp và một số làm đối số và trả về một tập hợp mới chứa tất cả các tập hợp con có độ dài
bằng hoặc nhỏ hơn số được cho
Write a Python function that takes two sets as arguments and returns True if one set is a subset of the other,
and False otherwise: Hàm Python nhận hai tập hợp làm đối số và trả về True nếu một tập hợp là tập con
của tập hợp kia, và False nếu ngược lại
Write a Python function that takes a set and returns True if all the elements in the set are even numbers, and
False otherwise: Hàm Python nhận một tập hợp làm đối số và trả về True nếu tất cả các phần tử trong tập
hợp là số chẵn, và False nếu ngược lại
Write a Python function that takes a set and returns True if there are no repeated elements in the set, and
False otherwise: Hàm Python nhận một tập hợp làm đối số và trả về True nếu không có phần tử lặp lại trong
tập hợp, và False nếu ngược lại
Write a Python function that takes two sets as arguments and returns True if the two sets are disjoint (i.e.,
have no common elements), and False otherwise: Hàm Python nhận hai tập hợp làm đối số và trả về True
nếu hai tập hợp không có phần tử chung (tập hợp rời rạc), và False nếu ngược lại
Write a Python function that takes a tuple as an argument and returns a new tuple containing the elements
of the original tuple in reverse order: Hàm để Đảo Ngược Một Tuple
Write a Python function that takes two tuples as arguments and returns a new tuple containing the elements
that are common to both tuples: Hàm để Trả về Các Phần Tử Chung Giữa Hai Tuple
Write a Python function that takes a tuple and a number as arguments and returns a new tuple containing
all elements of the original tuple that are greater than the given number: Hàm để Trả về Các Phần Tử Lớn
Hơn Một Số Cho Trước từ Một Tuple
Write a Python function that takes a list of tuples as an argument and returns a new tuple containing the
maximum element from each tuple: Hàm để Trả về Tuple Có Phần Tử Lớn Nhất Từ Mỗi Tuple Trong Danh
Sách Các Tuple
Write a Python function that takes a tuple and returns True if all the elements in the tuple are even numbers,
and False otherwise : Hàm để Kiểm Tra Xem Tất Cả Phần Tử Trong Tuple Có Phải Là Số Chẵn Hay
Không
Write a Python function that takes a tuple and returns a new tuple containing the cumulative sum of the
elements: Viết hàm Python nhận một bộ dữ liệu và trả về một bộ dữ liệu mới chứa tổng tích lũy của các
phần tử
Write a Python function that takes two tuples as arguments and returns True if the two tuples have the same
elements, regardless of their order, and False otherwise: Viết hàm Python lấy hai bộ dữ liệu làm đối số và
trả về True nếu hai bộ dữ liệu có các phần tử giống nhau, bất kể thứ tự của chúng và trả về Sai nếu ngược
lại
Write a Python function that takes a tuple and returns True if there are no repeated elements in the tuple,
and False otherwise: Viết hàm Python nhận một bộ dữ liệu và trả về True nếu không có phần tử lặp lại
trong bộ dữ liệu
Write a Python function that takes a tuple and a number as arguments and returns True if the number appears
at least twice in the tuple, and False otherwise: Viết hàm Python lấy một bộ và một số làm đối số rồi trả về
True nếu số đó xuất hiện ít nhất hai lần trong bộ, và trả về Sai nếu ngược lại
Write a Python function that takes two tuples as arguments and returns True if the second tuple is a
subsequence of the first tuple, and False otherwise : Hàm để Kiểm Tra Xem Tuple Thứ Hai Có Phải Là
Dãy Con của Tuple Thứ Nhất Hay Không

You might also like