Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions 1.basicProgramming/0.interpreterCommands
Original file line number Diff line number Diff line change
@@ -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


7 changes: 7 additions & 0 deletions 1.basicProgramming/1.helloworld.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import sys

def main():
print("hello world\n")
sys.exit(0)

main()
24 changes: 24 additions & 0 deletions 1.basicProgramming/2.conditionalStatement.py
Original file line number Diff line number Diff line change
@@ -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")
20 changes: 20 additions & 0 deletions 1.basicProgramming/3.forLoop.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'''
range (start_point , end_point , steps)

for <iterator name> in <the thing through which it is to be iterated> :


'''

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)