Tuesday 16 January 2024

Các khái niệm cơ bản trong Python

f-String:

F-strings are prefixed with the letter 'f' and are useful for creating strings where you want to include the values of variables or expressions



name = "Alice"

age = 30


# Using an f-string to include variables in a string

message = f"My name is {name} and I am {age} years old."

print(message)

Round Up

first we have to import math:

import math
round_up = math.ceil(number_to_round_up)

it will round up to the ceiling

Find position in a list

fruits = ['apple', 'banana', 'cherry']

x = fruits.index("cherry")

print(x)

result will be 2

No comments:

Post a Comment

Mức thuế ở Úc từ 07/2024

Chính phủ Úc đã thay đổi các mức thuế suất cho thu nhập cá nhân và các mức thu nhập (được gọi là ‘ngưỡng’) áp dụng những thuế suất này. Việc...