Download presentation
Presentation is loading. Please wait.
Published byJulian Allison Modified over 9 years ago
1
ברוכים הבאים ! מבוא לקורס ולשפת Python מבוא לבינה מלאכותית (236501) מדעי המחשב, טכניון חורף 2015-16
2
קצת מנהלות... ברוכים הבאים לקורס ! דרישות קדם : מבני נתונים, אלגוריתמים. מטלות הקורס : -3 תרגילי חובה המשלבים תכנות ב Python ודו " ח יבש. - בחינה מסכמת. הרכב הציון : שב 1 שב 2 שב 3 מבחן 40% + בונוסים 60%
3
מטלות הקורס תרגיל 1 – בעיית חיפוש ברשת כבישים תרגיל 2 – תחרות משחק שני שחקנים תרגיל 3 – ניסוי בתחום הלמידה
4
על הקורס... - זהו קורס מבוא לתחום המרתק של בינה מלאכותית. -" מבוא " – במהלך הסמסטר נטעם מהתחום, לא נסיים כמומחים. קיימות אפשרויות להמשך העמקה בפקולטה ומחוצה לה. -" קורס מתקדם " - נניח ידע ביסודות מדעי המחשב : תכנות, אלגוריתמים, מבני נתונים ומתמטיקה. - אופי הקורס יוריסטי בדגש אמפירי תוך שילוב מיומנויות תכנות בתרגילי הבית. - מתמטיקה פורמאלית, בעיקר תורת הקבוצות, תופיע לעיתים אך אינה הדגש. - תכנות ב Python – מעט היום, הרבה בבית !
5
מהי בינה מלאכותית ? - מבחן טיורינג : מערכות המסוגלות לחקות אדם. - סוכני תוכנה \ חומרה אוטונומיים המסוגלים לחוש, לתכנן, להסיק מסקנות, להכליל, ללמוד, להפעיל. The study and design of intelligent agents (Poole et al. ‘98) The science and engineering of making intelligent machines (McCarthy, ‘95) The science of making computers do things that require intelligence when done by humans (http://www.alanturing.net)http://www.alanturing.net Deduction, reasoning & problem solvingKnowledge representation PlanningLearningNatural language Motion and manipulationPerception Social intelligenceCreativityGeneral intelligence (Wikipedia)
6
מה נלמד בקורס ? הגדרת מרחבי מצבים לבעיה אלגוריתמי חיפוש מיודעים ולא מיודעים במרחבים משחקים - אלגוריתם Minimax ו - ווריאציות שלו ייצוג אילוצים לוגיים וחיפוש פתרון ( Constraint Satisfaction Problems ) מערכות לומדות (Machine Learning) ואולי נושאים נוספים...
8
Python – מקורות מומלצים ( ללמידה עצמית ) האתר הרשמי : http://python.org/ http://python.org/ ( מכאן גם מומלץ להוריד את הסביבה – שימו לב ! גרסה 3.4) המדריך הרשמי : https://docs.python.org/3.4/tutorial/ https://docs.python.org/3.4/tutorial/ חומרים נוספים ברשת : stackoverflow, אתרי אוניברסיטאות ואחרים.
9
Python על קצה המזלג Compact code - פיתוח קצר ומימוש מהיר. High Level - מבני נתונים אבסטרקטיים ( מילון ורשימה כטיפוסים פרמיטיבים ). Interpreted - קוד מפוענח בזמן ריצה ומתבצע. Dynamic typing – הטיפוס נקבע בזמן ריצה. Strongly typed - המרות לא טריוויאליות רק בדרישה מפורשת. Object Oriented - מחלקות, אובייקטים, ירושה וכיו " ב '. Platform compatible Virtual Machine,: Win 32/64, Unix, Linux, Mac...
10
Python vs. C/C++ C \ C++ 1.Code 2.Compile 3.Run Much Shorter!!! Python 1.Code 2.Run Another option (Interactive shell): 1. Code & Run!
11
Built-in types
12
Basic arithmetics: + - * / Modulu: % Div: // Power: ** Boolean bit ops: & (and) | (or) ^ (xor) ~ (neg 2’s comp.) Bit shift: > Assign and op: +=, **=, ^= etc… Logical:and, or, not Comparison:, =, == Generally, Operators are overloaded for all reasonable operand types Basic operators
13
Python Interpreter as a calculator
14
Variables -No variable declaration -Defined upon assignment -Variable type and value are defined by last value assigned -Therefore type may change dynamically (thus “Dynamic Typing”)
15
if, elif, else -input() for getting an input string -int() casting -Note the ‘:’ in the syntax -Indentation matters (no curly brackets) -The interpreter waits for code completion with secondary prompt (‘…’) -Note the multiple condition 0 <= x <= 9
16
While loop -Again note the ‘:’ and indentation -continue & break commands like in C -Note the optional ‘while - else’
17
list type -Empty list definition using [ ] -Elements may be of any type and different types in same list -Basic ops: +, *, append(), extend(), [ndx], len, in, del -range( ) creates immutable sequences of ints -range() is lazy, evaluates next value when requested -Slicing for read or write [from : to], [from : to : jumps] -Note the possibility of omitting one or both of the limits (from, to) -Note the [::-1] giving the entire list but in reverse order
18
for loop -for in : -Note the formatted print using %d %s %f similar to C -There are also other ways to print variables -Again note the optional ‘else’
19
functions -def ( ): … return -After defined, the function name becomes an object identifier -It may be assigned to a variable and has methods like any object -A function can return more than one type of value (not recommended) -Can also return multiple values
20
dictionary -A dictionary is an “assosiative array”, a set of : pairs -Each key may be any immutable type -Values may be mutable -The empty dictionary is { } -Functions used here: chr, ord, zip -Note the “List comprehension” syntax in the assignment to values (2 nd line)
23
classes - Tree inherits object- __init__() is the constructor - ‘self’ is a convention name for “this”- Members defined by assignment - Default values defined with ‘=‘ (like C++)- NewTreeMain module imports Tree - Notice the check __name__ == ‘__main__’ to avoid runing imported modules
24
טיפים מומלץ לעבוד עם IDE כמו Eclipse או Pycharm. לבדיקות קצרות - השתמשו ב shell. השתמשו ב list/dict comprehension- לצמצום הקוד. נצלו את מבני הנתונים של פייתון, במיוחד dictionaries. היעזרו ב -python manual המגיע עם ההתקנה של פייתון.
25
Practice - Python hands on טעמנו קצת, מומלץ מאוד לקרוא את המדריך הרשמי של פייתון : https://docs.python.org/3.4/tutorial/ https://docs.python.org/3.4/tutorial/ נושאים חשובים נוספים : Exceptions, Modules & Packages, I\O with Files, variable scope, standard libs, … תרגיל התנסות לא להגשה נמצא באתר. אתם מוזמנים לשלוח באימייל למתרגלים : –שאלות, הערות והמלצות לפרסום ב FAQ ( גישת קהילת לומדים ) מומלץ בחום לנסות ולהתמודד. הניסיון עשוי לעזור בתרגילים הבאים...
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.