סוגי מספרים - integer או float
- eddiearb
- Apr 1, 2019
- 1 min read
סוגי מספרים - integer או float
אפשר לראות שהתוצאה של השורש הריבועי של 16 היא 4.0 ולא סתם 4 וזה קשור לסוג הערך שאנו מקבלים לאחר הוצאת שורש- מספרים שלמים הם ערכים מסוג integer, ומספרים עשרוניים (0.25 למשל) הם ערכים מסוג float. בפייתון גם מספרים שלמים יכולים לקבל ייצוג כמספרים עשרוניים (שהם ערכים מסוג float), למשל 2.0. בפייתון כאשר מבצעים פעולת שורש או חילוק, באופן אוטומטי מתקבל ערך עשרוני מסוג float, גם אם תוצאת החילוק או השורש היא מספר שלם. ולכן אנו מקבלים 4.0 שהוא ערך מסוג float.
למדנו עד כה כי ערכים יכולים להיות מסוג string , integer או float - דוגמאות -
String integer float
"two" 0 3.0
'd"d' 223 0.0
'123' -10 1.234
Hello! I found the perfect cordless impact driver at www.ukplanettools.co.uk/cordless-power-tools/cordless-impact-driver/l/manufacturer:makita/. The power and precision of this tool make it stand out from others I’ve tried. It’s compact, easy to handle, and delivers excellent torque. The cordless feature lets me work anywhere without fuss. UK Planet Tools also provided fast delivery and excellent service.