14 JUN 2019

We studied range command which generates a range of numbers in ascending or descending order (also supportS gaps, i.e. jumping by 2). we saw how to use a for loop over a range of numbers, i.e. print the numbers between 1-100, or 100-1000 etc. we created a list out of a range using the list keyword combined with the range keyword. for example: list(range(1, 100, 3)). we learned while loop and do-while loop. these types of loops are used whenever we want to make a loop with an exit condition. for example: read numbers from the user until the user enters a negative number… the main difference between while loop and do-while loop is that the while loop will NOT execute even once if the exit condition occurs, in oppose to do-while loop which will always be executed once before checking the exit condition. break will terminate the loop and “jump” out of the loop. continue will skip the current iteration and “jump” to the next iteration. we practiced the while loop by writing a calculator which performs mathematical operations depending on the user input, until the user enters ‘Q’ . finally, we learned about the debugger in PyCharm. the debugger helps us to run our program line-by-line to inspect the flow. it also shows us the value of the memory cells used by our program (variables).   

More topics covered:

  • Better doing String comparison using upper( )
  • Boolean variables
  • Boolean names: isAbove10, didUserAgreed, etc.
  • Reverse range = range (5, 1, -1)
  • ”.join (list) will turn a list into one long string
  • Finding max number in a list (without max command )
  • Finding min number in a list (without min command)
  • Python do-while is implemented using while True and break
  • Debugger Step-Into and Step-Over

Links:

07 JUN 2019

We studied new string functions and new list functions. Then, We studies loops. we began with forloop (which is also called foreach loop). for-loop iterates over a list and “visits” all of the items in a sequentially order.  We wrote a for-loop to iterate over a list of strings (i.e.: [‘danny’, ‘orli’, ‘yossi’]) and a a for-loop to iterate over a list of numbers (i.e.: [2, -200, 3, 4, 100]). We saw the break command, which exits the for current loop immediately. as an example we wrote a python code which sums up numbers in a given list- until we reach the end of the list or until we reach a a total sum of 100 (using break). In the last part of the lesson we saw how to write a nested for-loop, which is a loop inside a loop (parent-child loop). we used it to iterate through a parent list which contains a child list. i.e.: [ [11, 9, 100] , [-5, 1000, 200], [5], [2, 4, 2, 1] ]. we saw that break in the inner loop only exists the inner loop, but the parent loop keeps going on

More topics covered:

  • Sorted command – sort and also returns a new list
  • reversed command – reverse and also returns a new list
  • Debugger usage – introduction
  • boolean
  • print using f:  print ( f'{a} + {b} = {c}’)

Links:

31 May 2019

We learned how to install PyCharm. we created our first project and a .py file to store our code. we ran our program in the PyCharm Terminal using the Play button (or Ctrl+Shift+F10). we saw how to get string from the user keyboard using the input command. we used int( ) and float( ) commands in order to change the input string into a number. we saw how to split a string using split( ). the split command creates a list. a list type is very similar to a string type except that each item in a list could be in any type. in contrary to a string, where each item is a character. however, commands such as len( ) and [ ] work the same. we saw the print command. and how to format a string using { }. finally, we saw how to write conditions: if, else, elif and how to use spaces to separate between if and else code

More topics covered:

  • if:  >  <  ==  !=  >=  <=  and  or
  • “a.b.c”.split(“.”) => [‘a’, ‘b’, ‘c’]
  • “a.b.c”.split( ) => [“a.b.c”]
  • print( “{ } + { } = { }”.format(x, y, x + y) )
  • print( “{:.2f} “.format(3.333) ) => 3.33
  • ‘a’ in [‘a’, ‘b’, ‘c’] ==> True

Links:

INT College

Welcome!! 

We learned how to install Python. we saw the python.org site. we opened the python terminal and executed some basic commands. we learned about memory cells and few types: int, float, string. we saw how to access a string using brackets [ ] and few helper functions

More topics covered:

  • string len method
  • string [ minus numbers ]
  • type command
  • print (“\n” * 100)

Links: