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: