Notice: file_put_contents(): Write of 10426 bytes failed with errno=28 No space left on device in /var/www/tg-me/post.php on line 50
Kaizonova | Telegram Webview: kaizonova/898 -
Telegram Group & Telegram Channel
Python3 Programming #post_7

### تحويل البيانات في بايثون (Python Casting)

#### تحديد نوع المتغير
في بعض الأحيان، قد ترغب في تحديد نوع معين لمتغير. يمكن القيام بذلك باستخدام التحويل. بايثون هي لغة موجهة للكائنات، وبالتالي تستخدم الفئات (Classes) لتعريف أنواع البيانات، بما في ذلك أنواعها الأساسية.

يتم تنفيذ التحويل في بايثون باستخدام دوال الإنشاء (Constructor Functions) التالية:

- **int()** - تقوم بإنشاء عدد صحيح (Integer) من قيمة صحيحة، أو عدد عشري (مع إزالة الأجزاء العشرية)، أو من سلسلة نصية بشرط أن تمثل السلسلة عددًا صحيحًا.
- **float()** - تقوم بإنشاء عدد عشري (Float) من قيمة صحيحة أو سلسلة نصية بشرط أن تمثل السلسلة عددًا عشريًا أو عددًا صحstr()*str()** - تقوم بإنشاء سلسلة نصية (String) من مجموعة واسعة من أنواع البيانات مثل النصوص، الأعداد الصحيحة، والأعداد العشرية.

#### الأعداد الصحيحة (Integers):gers):**

x = int(1)   # x سيكون 1
y = int(2.8) # y سيكون 2
z = int("3") # z سيكون 3

**الأعداد العشرية (Floats):**

x = float(1)     # x سيكون 1.0
y = float(2.8) # y سيكون 2.8
z = float("3") # z سيكون 3.0
w = float("4.2") # w سيكون 4.2

**السلاسل النصية (Strings):**

x = str("s1")  # x سيكون 's1'
y = str(2) # y سيكون '2'
z = str(3.0) # z سيكون '3.0'

#### تمرين:
ما هي نتيجة الكود التالي؟

print(int(35.88))

- 35
- 35.88
-Python CastingPython Casting**

#### Specify a Variable Type
There may be times when you want to specify a particular type for a variable. This cacastingsing **casting**. Python is an object-oriented language, and as such, it uses classes to define data types, including its primitive types.

Casting in Python is done using the following constructoint()ns:

- **int()** - constructs an integer from an integer literal, a float literal (by removing all decimals), or a string literal (as long as the string represents a wfloat()).
- **float()** - constructs a float from an integer literal, a float literal, or a string literal (as long as the string represents a float orstr()er).
- **str()** - constructs a string from a wide range of data types, including strings, integer literals, and float literals.

Integers::

**Integers:**

x = int(1)   # x will be 1
y = int(2.8) # y will be 2
z = int("3") # z will be 3

**Floats:**

x = float(1)     # x will be 1.0
y = float(2.8) # y will be 2.8
z = float("3") # z will be 3.0
w = float("4.2") # w will be 4.2

**Strings:**

x = str("s1")  # x will be 's1'
y = str(2) # y will be '2'
z = str(3.0) # z will be '3.0'

#### Exercise:
What will be the result of the following code?

print(int(35.88))

- 35
- 35.88
- 36
:)



tg-me.com/kaizonova/898
Create:
Last Update:

Python3 Programming #post_7

### تحويل البيانات في بايثون (Python Casting)

#### تحديد نوع المتغير
في بعض الأحيان، قد ترغب في تحديد نوع معين لمتغير. يمكن القيام بذلك باستخدام التحويل. بايثون هي لغة موجهة للكائنات، وبالتالي تستخدم الفئات (Classes) لتعريف أنواع البيانات، بما في ذلك أنواعها الأساسية.

يتم تنفيذ التحويل في بايثون باستخدام دوال الإنشاء (Constructor Functions) التالية:

- **int()** - تقوم بإنشاء عدد صحيح (Integer) من قيمة صحيحة، أو عدد عشري (مع إزالة الأجزاء العشرية)، أو من سلسلة نصية بشرط أن تمثل السلسلة عددًا صحيحًا.
- **float()** - تقوم بإنشاء عدد عشري (Float) من قيمة صحيحة أو سلسلة نصية بشرط أن تمثل السلسلة عددًا عشريًا أو عددًا صحstr()*str()** - تقوم بإنشاء سلسلة نصية (String) من مجموعة واسعة من أنواع البيانات مثل النصوص، الأعداد الصحيحة، والأعداد العشرية.

#### الأعداد الصحيحة (Integers):gers):**

x = int(1)   # x سيكون 1
y = int(2.8) # y سيكون 2
z = int("3") # z سيكون 3

**الأعداد العشرية (Floats):**

x = float(1)     # x سيكون 1.0
y = float(2.8) # y سيكون 2.8
z = float("3") # z سيكون 3.0
w = float("4.2") # w سيكون 4.2

**السلاسل النصية (Strings):**

x = str("s1")  # x سيكون 's1'
y = str(2) # y سيكون '2'
z = str(3.0) # z سيكون '3.0'

#### تمرين:
ما هي نتيجة الكود التالي؟

print(int(35.88))

- 35
- 35.88
-Python CastingPython Casting**

#### Specify a Variable Type
There may be times when you want to specify a particular type for a variable. This cacastingsing **casting**. Python is an object-oriented language, and as such, it uses classes to define data types, including its primitive types.

Casting in Python is done using the following constructoint()ns:

- **int()** - constructs an integer from an integer literal, a float literal (by removing all decimals), or a string literal (as long as the string represents a wfloat()).
- **float()** - constructs a float from an integer literal, a float literal, or a string literal (as long as the string represents a float orstr()er).
- **str()** - constructs a string from a wide range of data types, including strings, integer literals, and float literals.

Integers::

**Integers:**

x = int(1)   # x will be 1
y = int(2.8) # y will be 2
z = int("3") # z will be 3

**Floats:**

x = float(1)     # x will be 1.0
y = float(2.8) # y will be 2.8
z = float("3") # z will be 3.0
w = float("4.2") # w will be 4.2

**Strings:**

x = str("s1")  # x will be 's1'
y = str(2) # y will be '2'
z = str(3.0) # z will be '3.0'

#### Exercise:
What will be the result of the following code?

print(int(35.88))

- 35
- 35.88
- 36
:)

BY Kaizonova


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/kaizonova/898

View MORE
Open in Telegram


Kaizonova Telegram | DID YOU KNOW?

Date: |

Telegram has exploded as a hub for cybercriminals looking to buy, sell and share stolen data and hacking tools, new research shows, as the messaging app emerges as an alternative to the dark web.An investigation by cyber intelligence group Cyberint, together with the Financial Times, found a ballooning network of hackers sharing data leaks on the popular messaging platform, sometimes in channels with tens of thousands of subscribers, lured by its ease of use and light-touch moderation.

The STAR Market, as is implied by the name, is heavily geared toward smaller innovative tech companies, in particular those engaged in strategically important fields, such as biopharmaceuticals, 5G technology, semiconductors, and new energy. The STAR Market currently has 340 listed securities. The STAR Market is seen as important for China’s high-tech and emerging industries, providing a space for smaller companies to raise capital in China. This is especially significant for technology companies that may be viewed with suspicion on overseas stock exchanges.

Kaizonova from us


Telegram Kaizonova
FROM USA