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

Comments