🎯 تمارين عملية: الدرس 1

أساسيات بايثون - الطباعة، المتغيرات، النصوص، والعمليات الحسابية

📝 المهام (7 تمارين)

1 Print with end
2 Comments
3 Variable Unpacking
4 Value Swapping
5 String Slicing
6 String Format
7 Input & Type Cast
Print "Hello" and "Python" on the same line with a space between them using end=" "
اطبع "Hello" و "Python" على نفس السطر مع مسافة بينهما باستخدام end=" "
💡 استخدم print("Hello", end=" ") ثم print("Python")
Write code with a single-line comment (#) and a multi-line comment (""" """)
اكتب كوداً يحتوي على تعليق من سطر واحد (#) وتعليق متعدد الأسطر (""" """)
💡 استخدم # للتعليق من سطر واحد و """ للتعليقات المتعددة
Create three variables x, y, z with values 10, 20, 30 using unpacking in one line
أنشئ ثلاثة متغيرات x, y, z بقيم 10, 20, 30 باستخدام الفصل في سطر واحد
💡 استخدم x, y, z = 10, 20, 30
Create two variables a=5 and b=10, then swap their values using Python's Pythonic way
أنشئ متغيرين a=5 و b=10، ثم بدّل قيمهما باستخدام الطريقة البايثونية
💡 استخدم a, b = b, a للتبديل المباشر
Given text="Python", get the first 3 characters using slicing and reverse the entire string
معطى text="Python"، احصل على أول 3 أحرف باستخدام التقطيع واعكس النص بالكامل
💡 استخدم text[:3] للأحرف الأولى و text[::-1] لعكس النص
Create name="Ali" and age=20, then print "My name is Ali and I'm 20 years old" using .format()
أنشئ name="Ali" و age=20، ثم اطبع "My name is Ali and I'm 20 years old" باستخدام .format()
💡 استخدم "My name is {} and I'm {} years old".format(name, age)
Get user input for a number, convert it to integer, then calculate its square (x**2)
اطلب من المستخدم إدخال رقم، حوّله إلى عدد صحيح، ثم احسب مربعه (x**2)
💡 استخدم x = int(input("Enter number: ")) ثم print(x ** 2)
# Output will appear here... # النتيجة ستظهر هنا...