You are on page 1of 2

‫סיכום מפגש ‪ 4‬קורס יסודות התכנות ‪ /‬קרן כץ בקרמן תשפד‬

‫חזרה על ‪ IF‬הכנסה של תשובת בדיקה בוליאנית לתוך משתנה בוליאני‬


‫שימוש בו בדוגמת הציונים של הפסיכומטרי וציוני הבגרות‬

‫))" ‪SATScore = int(input("Please enter the SAT score:‬‬


‫))" ‪MatAverage = int(input("Please enter the matriculation exams average:‬‬
‫))" ‪EngScore = int(input("Please enter the English score:‬‬

‫‪passedSATThresh = SATScore >= 580‬‬


‫‪passedMatThresh = MatAverage >= 90‬‬
‫‪passedEngThresh = EngScore >= 100‬‬

‫‪if passedSATThresh and passedMatThresh and passedEngThresh:‬‬


‫)"!‪print("\nCongratulations!! You have been accepted‬‬
‫‪else:‬‬
‫)"‪print("\nSorry, your scores do not pass the threshold. You are not accepted‬‬
‫לולאות ‪ FOR‬דוגמא של ‪ FOR‬שלאחריו ‪ ELSE-‬הרחבה של הלולאה‪ .‬מקרה מיוחד שצריך לזכור‬
‫ולהבין אותו‬
‫‪ ,‬הוא שונה מאשר ‪ ELSE‬של ‪.IF‬‬
‫דוגמת חשיבה אלגוריתמית‪ :‬דוגמא המשתמשת במשתנה בוליאני‪ -‬חשיבות השם ‪hasFound‬‬
‫האתחול ב‪false‬‬
‫לולאות‪ :‬לולאת ‪while‬‬
‫המשמעות הלוגית של 'כל עוד'‬
‫הצורך לקדם בתוך הלולאה ‪ ,‬אחרת נגיע ללולאה אינסופית‬
‫טבלת הרצה 'על יבש' – אל מול דיבגר ‪debugger‬של הפיצ'ארם‬
‫לולאה בתוך לולאה‪:‬‬
‫המובן של לולאה חיצונית‪ ,‬ולולאה פנימית‬
‫הלולאה החיצונית‪ -‬כמשהו קבוע‪ .‬הלולאה הפנימית כמשהו משתנה‪.‬‬
‫הדימיון לשעות‪ -‬דקות‪ .‬השימוש המוכר כ שורות‪/‬עמודות‪.‬‬
‫תרגילים ‪ :‬כתיבת לוח הכפל‪.‬‬
.‫ כאשר יש תלות בין הלולאה הפנימית אל החיצונית‬-‫כתיבת משולש כוכביות‬
#3/1/2021 while loops keren katz beckerman
n = (int)(input("Enter positive number (negative to stop)"))
sum = count = 0

while n > 0 :
sum += n
count += 1
n = (int)(input("Enter positive number (negative to stop)"))
if count>0:
average = float(sum) / count
print(average)
######### count digits in number
n = (int)(input("Enter a number:"))
count = 0
while n > 0:
n //= 10
count += 1
print(count)
#########mult table
for i in range(1,11):
for j in range(1,11):#[1,2,3,4,5,6,7,8,9,10]
print(i*j ,"\t",end="")
print()

### triangle of stars


for i in range(1,7):
for j in range(1,i+1):#
print("*" ,"\t",end="")
print()

You might also like