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

How to connect to VPS with Private Key on Mac OS

1. Use the cd command to navigate to the directory where your private key file is stored. For example, if your private key is in the Downlo...