Ravindra Bagale · Data Scienceसर्व coursesया course चे lessonsशोधाEnglish

Data Science · मराठी आवृत्ती · Python basics

P2.4 Python Arithmetic Operators उदाहरणांसह

By Ravindra Bagale

हे का शिकायचं?

Discount, tax, सरासरी, boxes मोजणं — data कामात रोज गणित लागतं.

हे काय आहे?

+ बेरीज, - वजाबाकी, * गुणाकार, / भागाकार (नेहमी float), // पूर्ण भागाकार, % बाकी आणि ** घात. round(x, 2) दोन दशांशांपर्यंत गोल करतो.

कसं करायचं?

Step 1. Values variables मध्ये ठेवा.

Step 2. योग्य operator वापरा.

Step 3. पैशांसाठी round(x, 2) वापरा.

उदाहरणं: copy करा आणि चालवा

उदाहरण A: साधा discount

हा code चालवा:

price = 80
discount = price * 0.15
print(price - discount)

तुम्हाला दिसणारा output:

68.0

याचा अर्थ: Price मधून discount वजा करून final price मिळाली.

उदाहरण B: Items boxes मध्ये वाटा

हा code चालवा:

items = 53
print("Full boxes:", items // 12)
print("Items left:", items % 12)

तुम्हाला दिसणारा output:

Full boxes: 4
Items left: 5

याचा अर्थ: // किती पूर्ण boxes भरतात ते सांगतो आणि % किती items उरतात ते.

उदाहरण C: पैशांची value round करा

हा code चालवा:

share = 100 / 3
print(share)
print(round(share, 2))

तुम्हाला दिसणारा output:

33.333333333333336
33.33

याचा अर्थ: round(x, 2) दोन दशांशांपर्यंत गोल करतो, पैशांसाठी हेच हवं.