TGViewer
Data Science & Machine Learning Data Science & Machine Learning @datasciencefun ยท 77.8K subscribers
Post #4414 2.76K
<class 'int'>


๐Ÿ”น 11. Type Conversion (Casting)

Sometimes you need to convert one data type into another.

String โ†’ Integer

age = "25"
print(int(age))


Integer โ†’ Float

marks = 95
print(float(marks))


Float โ†’ Integer

price = 199.99
print(int(price)) # Output: 199


Integer โ†’ String

number = 100
print(str(number))


๐Ÿ”น 12. Multiple Variable Assignment

Assign multiple variables in one line.

x, y, z = 10, 20, 30


Assign the same value to multiple variables.

a = b = c = 100


๐Ÿ”น 13. Dynamic Typing

Python is dynamically typed.

This means a variable can store different data types at different times.

x = 10
x = "Data Science"
print(x)
# Output: Data Science


๐Ÿ”น 14. Best Practices

โœ… Use meaningful variable names.

student_name = "Rahul"
monthly_salary = 50000


Instead of:

a = "Rahul"
b = 50000


Follow the snake_case naming convention.

Examples: customer_name, total_sales, average_salary

๐Ÿ”น 15. Real-World Example

name = "Rohit"
age = 25
salary = 65000.50
is_employee = True

print(name)
print(age)
print(salary)
print(is_employee)


Output:

Rohit
25
65000.5
True


๐ŸŽฏ Key Takeaways

โœ… Variables are used to store data.

โœ… Python automatically detects data types.

โœ… The most common data types are: int, float, str, bool, complex

โœ… Use type() to check a variable's data type.

โœ… Use meaningful variable names and follow the snake_case naming convention.

Mastering variables and data types is the first step toward becoming a successful Data Scientist. Every machine learning model, data analysis project, and AI application starts with understanding how data is stored and managed in Python.

Double Tap โค๏ธ For More
  • โค 17
  • ๐Ÿ‘ 1
More from @datasciencefun
  1. Oct 7, 2026ORDER BY salary DESC LIMIT 5; Mistake 3 โ€” Forgetting that LIMIT applies after sorting Forโ€ฆ
  2. Oct 7, 2026๐Ÿš€ Data Science Roadmap 2026 ๐Ÿ“ Phase 3: SQL for Data Science ๐Ÿ“– Topic 4 โ€” LIMIT LIMIT isโ€ฆ
  3. Oct 7, 2026๐Ÿš€๐—ฃ๐—ฎ๐˜† ๐—”๐—ณ๐˜๐—ฒ๐—ฟ ๐—ฃ๐—น๐—ฎ๐—ฐ๐—ฒ๐—บ๐—ฒ๐—ป๐˜ ๐—ง๐—ฟ๐—ฎ๐—ถ๐—ป๐—ถ๐—ป๐—ด | ๐—•๐—ฒ๐—ฐ๐—ผ๐—บ๐—ฒ ๐—ฎ ๐—™๐˜‚๐—น๐—น๐˜€๐˜๐—ฎ๐—ฐโ€ฆ
  4. Oct 7, 2026๐— ๐—ฎ๐˜€๐˜๐—ฒ๐—ฟ ๐—ฃ๐—ผ๐˜„๐—ฒ๐—ฟ ๐—•๐—œ ๐—ณ๐—ผ๐—ฟ ๐—™๐—ฅ๐—˜๐—˜! ๐Ÿ”ฅ Learn Power BI through these FREE learninโ€ฆ
  5. Oct 2, 2026Data Visualisation tips for beginners
  6. Sep 29, 2026๐—™๐—ฅ๐—˜๐—˜ ๐—ฅ๐—ฒ๐˜€๐—ผ๐˜‚๐—ฟ๐—ฐ๐—ฒ๐˜€ ๐—ง๐—ผ ๐—Ÿ๐—ฒ๐—ฎ๐—ฟ๐—ป ๐—”๐—œ ๐—ถ๐—ป ๐Ÿฎ๐Ÿฌ๐Ÿฎ๐Ÿฒ๐Ÿš€ โ€‹ Explore 6 free resourceโ€ฆ
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook โ†’Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 โ†’