From 2558115354e9644f0417b637731f2fe2a9f2f3d6 Mon Sep 17 00:00:00 2001 From: Atharva Dongare Date: Sat, 17 Oct 2020 03:08:05 +0530 Subject: [PATCH 1/4] Basic commands for running scripts using the terminal and excuting the python files --- 1.basicProgramming/0.interpreterCommands | 47 ++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 1.basicProgramming/0.interpreterCommands diff --git a/1.basicProgramming/0.interpreterCommands b/1.basicProgramming/0.interpreterCommands new file mode 100644 index 0000000..67437f4 --- /dev/null +++ b/1.basicProgramming/0.interpreterCommands @@ -0,0 +1,47 @@ +$python + -- invokes the interpreter +>>>quit() + -- exits from the interpreter +>>> help + -- gets help + +# at the start of the line denotes single line comment +# arithmatic operations +>>> 2 + 2 +4 +>>> 50 - 5*6 +20 +>>> (50 - 5*6) / 4 +5.0 +>>> 8 / 5 # division always returns a floating point number +1.6 +>>> 17 // 3 # floor division discards the fractional part +5 +>>> 17 % 3 # the % operator returns the remainder of the division +2 +>>> 5 * 3 + 2 # result * divisor + remainder +17 +>>> 5 ** 2 # 5 squared +25 + +# simple variable declaration +>>> width = 20 +>>> height = 5 * 9 +>>> width * height +900 + +# accessing the result of last operation with "_" +>>> tax = 12.5 / 100 +>>> price = 100.50 +>>> price * tax +12.5625 +>>> price + _ +113.0625 +>>> round(_, 2) +113.06 + +# simple printing +>>> print("simple printing") +simple printing + + From 520246f29db9a94529ac1e1c796f51dff9c19af1 Mon Sep 17 00:00:00 2001 From: Atharva Dongare Date: Sat, 17 Oct 2020 03:08:24 +0530 Subject: [PATCH 2/4] Hello world program --- 1.basicProgramming/1.helloworld.py | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 1.basicProgramming/1.helloworld.py diff --git a/1.basicProgramming/1.helloworld.py b/1.basicProgramming/1.helloworld.py new file mode 100644 index 0000000..64af789 --- /dev/null +++ b/1.basicProgramming/1.helloworld.py @@ -0,0 +1,7 @@ +import sys + +def main(): + print("hello world\n") + sys.exit(0) + +main() \ No newline at end of file From 321697dbe1b28648b8ca5aed434d565cb97620d4 Mon Sep 17 00:00:00 2001 From: Atharva Dongare Date: Sat, 17 Oct 2020 03:08:50 +0530 Subject: [PATCH 3/4] Conditional statements if-else and nested if-else: --- 1.basicProgramming/2.conditionalStatement.py | 24 ++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 1.basicProgramming/2.conditionalStatement.py diff --git a/1.basicProgramming/2.conditionalStatement.py b/1.basicProgramming/2.conditionalStatement.py new file mode 100644 index 0000000..f6d088f --- /dev/null +++ b/1.basicProgramming/2.conditionalStatement.py @@ -0,0 +1,24 @@ +""" +if else : + +nested if else: +""" + +a = 10 + +if a==10: + print(" a is 10") +else: + print ("i dont know") + + +if (a > 5): + print ("The number is greater than 5") + if (a > 7): + print("The number is greater than 7") + if (a > 9): + print ("The number is greater than 9") + if (a > 11): + print ("number is greater than 11") +else : + print ("I dont know") \ No newline at end of file From 0a346d4bdc10383bfe4d079e5c50ddf1388e0a72 Mon Sep 17 00:00:00 2001 From: Atharva Dongare Date: Sat, 17 Oct 2020 03:09:20 +0530 Subject: [PATCH 4/4] For loop and control with numeircal series and string series --- 1.basicProgramming/3.forLoop.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 1.basicProgramming/3.forLoop.py diff --git a/1.basicProgramming/3.forLoop.py b/1.basicProgramming/3.forLoop.py new file mode 100644 index 0000000..d176217 --- /dev/null +++ b/1.basicProgramming/3.forLoop.py @@ -0,0 +1,20 @@ +''' +range (start_point , end_point , steps) + +for in : + + +''' + +for i in range (1,10): + print (i) + +for j in range(1,10,2): + print (i) + +for k in range(10 ,1 ,-1): + print (i) + +sentence = "some_random_string" +for i in sentence : + print (i) \ No newline at end of file