انت هنا الان : شبكة جامعة بابل > موقع الكلية > نظام التعليم الالكتروني > مشاهدة المحاضرة

Dimension & Comprehensions

Share |
الكلية كلية تكنولوجيا المعلومات     القسم قسم شبكات المعلومات     المرحلة 1
أستاذ المادة هبه امير جابر الخفاجي       28/04/2018 08:28:34
So far everything is going according to plan. Where things start to go wrong just a little is when you attempt to push the similarities between lists and arrays one step too far.

Comprehensions
A comprehension is an expression that specifies a sequence of values - think of it as a compact for loop.
? In Python a comprehension can be used to generate a list. ? This means that we can use a comprehension to initialize a list so that it has a predefined size.

Two dimensions
? It has to be said that one-dimensional arrays are fairly easy - it is when we reach two or more dimensions that mistakes are easy to make. ? For a programmer moving to Python the problem is that there are no explicit provisions for multidimensional arrays.
As a list can contain any type of data there is no need to create a special twodimensional data structure. All you have to do is store lists within lists - after all what is a two-dimensional array but a one-dimensional array of rows.

-what is the two-dimensional equivalent of the dimension statement using comprehensions?
The answer is that we need to use a nested comprehension to create the list.

Advanced comprehensions
In Python there are lots of clever ways of doing things that you generally wouldn t dream of in a lesser language.

Python has lots of, usually functional, ways of working with arrays that aren t encountered in other languages. This should be enough to get you started on using lists as arrays and in more creative ways.


المادة المعروضة اعلاه هي مدخل الى المحاضرة المرفوعة بواسطة استاذ(ة) المادة . وقد تبدو لك غير متكاملة . حيث يضع استاذ المادة في بعض الاحيان فقط الجزء الاول من المحاضرة من اجل الاطلاع على ما ستقوم بتحميله لاحقا . في نظام التعليم الالكتروني نوفر هذه الخدمة لكي نبقيك على اطلاع حول محتوى الملف الذي ستقوم بتحميله .
الرجوع الى لوحة التحكم