डेवलपर्स के लिए Python परिचय
Jasmin Ludolf
Senior Data Science Content Developer
# मात्रा परिभाषित करें quantity = 10# सिंगल quotes ingredient_name = 'pasta'# डबल quotes भी चलती हैं ingredient_name = "pasta"
ingredient_name = "Basil Leaves"# लोअरकेस में बदलें ingredient_name = ingredient_name.lower()
# ingredients की लिस्ट ingredients = ["pasta", "tomatoes", "garlic", "basil", "olive oil", "salt"]# पहले index का मान लें ingredients[0]
# एक dictionary बनाएँ
recipe_dict = {"pasta": 500,
"tomatoes": 400,
"garlic": 15,
"basil": 20,
"olive oil": 30,
"salt": 5}
# एक set बनाएँ ingredients_set = {"pasta", "tomatoes", "pasta", "basil", "garlic", "olive oil", "salt"}# एक tuple बनाएँ serving_sizes = (1, 2, 4, 6, 8)
| Operator | Function |
|---|---|
== |
बराबर |
!= |
बराबर नहीं |
> |
से अधिक |
>= |
से अधिक या बराबर |
< |
से कम |
<= |
से कम या बराबर |
| Keyword | Function | Use |
|---|---|---|
if |
शर्त सही हो तो | workflow का पहला चरण |
elif |
नहीं तो, अगली शर्त जाँचें | if के बाद |
else |
नहीं तो, यह करें | elif के बाद |
# ingredients की लिस्ट ingredients = ["pasta", "tomatoes", "garlic", "basil", "olive oil", "salt"]# loop चलाकर हर ingredient प्रिंट करें for ingredient in ingredients:print(ingredient)
pasta
tomatoes
garlic
basil
olive oil
salt
ingredients_to_add = 5
items_added = 0
while items_added < ingredients_to_add:
items_added += 1
remaining = ingredients_to_add - items_added
if remaining > 3:
print("कई ingredients बाकी हैं")
elif remaining >= 1:
print("लगभग हो गया!")
else:
print("शॉपिंग लिस्ट पूरी!")
| Keyword | Function |
|---|---|
and |
जाँचें कि कई शर्तें सही हैं |
or |
जाँचें कि एक या अधिक शर्तें सही हैं |
in |
जाँचें कि कोई मान data structure में है |
not |
जाँचें कि कोई मान data structure में नहीं है |
list.append()अतिरिक्त built-in functions
zip()enumerate()Packages और modules
ostimevenvpandasrequestsnumpy$$
डेवलपर्स के लिए Python परिचय