Data Types Part-05

WBOY
Release: 2024-08-29 14:32:32
Original
586 people have browsed it

Data Types Part-05

I'm learning new programming and don't feel like drinking new coffee. Boring. So I thought I should try something new. The only alternative to coffee is tea. After searching for a while, I realized that I don't have the necessary materials for making tea. So what can be done? There is only one option.

Now I am walking towards the tea shop. After a short distance, I met two friends. One of them asked,

“Where are you going?”

“Going to have tea.”

“Is that so.”

“Will you go? ”

“Yes, let's go too.”

3 people had tea together (I drank more). With biscuits. After tea, it's time to pay the bill. Now I asked my friends for money. One said

“You are a computer engineer. You are a big guy"

I smiled a little after hearing what the big guy said.

“You pay the bill. And we came with you. It is your moral responsibility to pay the bill”

“Okay okay. I'm paying the bill”

I know very well that I will never be able to deal with them.

When the shopkeeper uncle asked about the tea bill, he thought for a while. You are calculating in your mind. After some time he said. I settled the bill and left. Got my energy back. That's why I thought I needed to learn something about programming. After mulling around for a while, I decided to learn Python's data types. I opened 2-3 blogs from online and selected one from them and started reading. At first I didn't understand anything, but slowly something started to come to my mind. For a while I said

“I know them. This is what I use every day."

After reading the entire blog, I felt these things should be noted. So I noted the necessary things and looked at the clock. I have some time. So I decided to go to Facebook. Open Facebook and see your message. You're in trouble, the data type isn't coming to mind. As there is time let's teach you data types.

Do you know what the data type is? don't know Data type is the type of data. What kind of data will it be? There were two types of numbers when he did math in small classes. Whole numbers and fractions. Two are two types of numbers. Integer and fraction are two different data types.

Data types are basically of 2 types.

  • Primitive
  • Non-primitive.

Primitive data types are those data types that already exist.

  • Integer
  • Float (decimal number)
  • Boolean (True/False)
  • String (Text)

are non-primitive data types and those data types are created using already existing data types.

  • List
  • Tuple
  • Dictionary etc.

A question may come in your mind is there any need to learn data types?

Of course there is. We know very well that computers have no ability to act on their own. He will work as we direct him. Now suppose you have to add 2 numbers. You didn't tell the computer what type the number two was. After some time the result is wrong. Where is the problem here?

The problem is that the computer does not know what type of number two is. Now he will make an assumption of his own and give the result. Which will show wrong most of the time.

Note: Python does not need to specify the data type separately. Python's compiler does not automatically select the data type .

Integer

Bengali meaning of

Integer is whole number. That is, starting from 0, 1, 2 and all the subsequent and previous numbers are integers.

In the above problem if you say Integer in the number field then the computer will add the result as integer works or add.

Now tell me what data type is the bill I gave to the tea shopkeeper?

Run the code below

intVar = 10
print(type(intVar))
Copy after login

Output will come as below.

<class 'int'>
Copy after login
The short form of

Integer is int.

Float

Now come to float. What is the Bengali meaning of Float? If you know then it is good. If not, there is google translate.

Anyway, you understand decimal numbers. 20.5 (20.5), 27.9 (27.9). If you want to say English, 20 point 5(20.5), 27 point 9(27.9). Now tell me what is your SSC result?

এই যে পয়েন্ট বা দশমিক দিয়ে কোন সংখ্যা লিখছি, এই ধরনের সকল সংখ্যা গুলোই হল Float ডাটা টাইপ এর অন্তর্ভুক্ত।

নিচের কোড টা রান করুন

intVar = 20.5
print(type(intVar))
Copy after login

Output নিচের মত আসবে।

<class 'float'>
Copy after login

String

এখন আমি যদি আপনার নাম জিজ্ঞাসা করি আপনি বলবেন “আমার নাম পাইথন”। এখন আপনার কাজ হচ্ছে এই লেখা টা কম্পিউটারে সেভ করতে হবে। কম্পিউটারে কিভাবে সেভ করবেন। কম্পিউটার কে তো বলে দিতে হবে। এটা কি?

যখন ‘’ বা “” এর মধ্য যখন কোন কিছু রাখা হয় তখন তাকে String বলা হয়।

নিচের কোড টা রান করুন

name = 'I am Python'
print(type(name))
Copy after login

Output নিচের মত আসবে।

<class 'str'>
Copy after login

str হল string সর্ট ফর্ম।

Boolean

এখন আমি যদি আপনাকে জিজ্ঞাসা করি,

আপনি কি সকাল সকাল ঘুম থেকে উঠেন ? অথবা

আপনি কি প্রতিদিন সকালে গোসল করে কাজে যান?

আপনি কি রাতে ঘুমানোর আগে বাইরে হাটতে যান ?

আপনি কি রাতে ঘুমানোর আগে বই পড়েন?

প্রশ্ন গুলো একটু এনালাইসিস করুন। কিছু পেলেন?

এখানে যত গুলো প্রশ্ন আছে, সব গুলোর উত্তর হ্যা অথবা না দিয়ে দিতে হবে। বুলিয়ান ডাটা টাইপ ঠিক একই ধরনের হয় হ্যা হবে নতুন না হবে। হ্যা বলতে True এবং না বলতে False কে বোঝায়।

নিচের কোড টা রান করুন

boolValue1 = True
boolValue2 = False
print(type(boolValue1))
print(type(boolValue2))
Copy after login

Output নিচের মত আসবে।

<class 'bool'>
<class 'bool'>
Copy after login

bool হল Boolean সর্ট ফর্ম।

কিছু মনে পড়েছে? আমিও কিন্তু বুলিয়ান এর ব্যবহার করেছি। কোথায় বলুন তো?

নন-প্রমিটিভ ডাটা টাইপ (list, tuple , set , dictionary) এর নিয়ে আলোচনার জন্য সামনের ব্লগ এ হবে। সাথে থাকার জন্য ধন্যবাদ

প্রশ্নের উত্তর গুলো জানাতে ভুলবেন না।

The above is the detailed content of Data Types Part-05. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!