Skip to content

Commit 122a13d

Browse files
committed
update
1 parent f8bfd93 commit 122a13d

12 files changed

Lines changed: 102 additions & 57 deletions

10_0_comandLine.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
# python ./10_0_comandLine.py 1 2 3
1+
# python3 ./10_0_comandLine.py 1 2 3
22
import sys
33

44
# total arguments
55
n = len(sys.argv)
66
print("Total arguments passed:", n)
77

88
# Print all command line arguments
9-
print("Arguments Passed:", sys.argv)
9+
print("Arguments Passed:", sys.argv) # ['10_0_comandLine.py', '1', '2', '3']
1010

1111
# Print the Script Name
12-
print("Script Name:", sys.argv[0])
12+
print("Script Name:", sys.argv[0]) # 10_0_comandLine.py
1313

1414
# Print First Argument
15-
print("First Argument:", sys.argv[1])
15+
print("First Argument:", sys.argv[1]) # 1
1616

1717
# Print Second Argument
18-
print("Second Argument:", sys.argv[2])
18+
print("Second Argument:", sys.argv[2]) # 2
1919

2020
# Print Third Argument
21-
print("Third Argument:", sys.argv[3])
21+
print("Third Argument:", sys.argv[3]) # 3

10_1_comandLine.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# python ./10_1_comandLine.py 1 add 3
22
# python ./10_1_comandLine.py 9 sub 3
33
# python ./10_1_comandLine.py 6 mult 3
4+
# alias calc="python3 ./10_1_comandLine.py"
5+
# calc 1 add 3
6+
# calc 9 sub 3
7+
# calc 6 mult 3
48
import sys
59

610
num1 = int(sys.argv[1])
@@ -17,4 +21,4 @@
1721
output = num1 * num2
1822
print(output)
1923
else:
20-
print("Please give the correct operator, it is add, sub, multi")
24+
print("Please give the correct operator, Any one( add, sub, multi)")

4_Dataypes_1_string.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
str = "HELLO" # immutable (can't be changebale)
2+
# H E L L O
3+
# 0 1 2 3 4
4+
print(str) # HELLO
25
print(str[2]) # L
36
print(str[2:5]) # LLO
7+
print(str[0:4]) # HELL
48
#str[0] = "h" # TypeError: 'str' object does not support item assignment
59
print(str)
610
str1 = "Python"
711
print(str1)
812
del str1
9-
print(str1) # NameError: name 'str1' is not defined. Did you mean: 'str'?
13+
print(str1) # NameError: name 'str1' is not defined. Did you mean: 'str'?
14+
print(a) # NameError: name 'a' is not defined

4_Dataypes_2_string_operator.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
str = "Hello"
1+
str = "Hello "
22
str1 = " world"
3-
print(str*3) # HelloHelloHello
4-
print(str+str1) # Hello world
3+
print(str*3) # Hello Hello Hello
4+
print(str+str1) # Hello world
55
print(str[4]) # o
66
print(str[2:4]) # ll
77
print('w' in str) # false as w is not present in str
88
print('wo' not in str1) # false as wo is present in str1.
9-
print("C:\\python37") # C://python37 as it is written
10-
print(r"C:\\python37") # C://python37 as it is written
9+
print("C:\\python37") # C:\python37 as it is written
10+
print(r"C:\\python37") # C:\\python37 as it is written
1111
print("%s string str : %s" % (str,"welcome")) # prints Hello string str : welcome

4_Dataypes_3_boolean

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
a = 1
2+
b = 1
3+
x = (a == b)
14
x = (1 == True)
25
y = (2 == False)
36
z = (3 == True)
@@ -15,4 +18,5 @@ print("p:", p)
1518
p = '' == False
1619
print("p:", p)
1720
p = 1 == True
18-
print("p:", p)
21+
print("p:", p)
22+

6_Slicing.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
planet1="Closest of Sun"
2+
# C l o s e s t o f S u n
3+
# 0 1 2 3 4 5 6 7 8 9 10 11 12 13
24
print(planet1)
35
"""
46
print(planet1[0]) # C
@@ -10,21 +12,21 @@
1012
print(planet1[-3]) # S
1113
1214
# Slicing a string, get a substring from a string
13-
print(planet1[1:4])
14-
print(planet1[:])
15-
print(planet1[:7])
16-
print(planet1[11:])
15+
print(planet1[1:4]) # los
16+
print(planet1[:]) # Closest of Sun
17+
print(planet1[:7]) # Closest
18+
print(planet1[11:]) # Sun
1719
1820
# Slicing Tuple
1921
devops=("Linux", "Vagrant", "Bash Scripting", "AWS", "Jenkins", "Python", "Ansible")
2022
print(devops[0])
2123
print(devops[4])
2224
print(devops[-1])
2325
24-
print(devops[2:5])
25-
print(devops[2:5][0])
26+
print(devops[2:5]) # ('Bash Scripting', 'AWS', 'Jenkins')
27+
print(devops[2:5][0]) # Bash Scripting
2628
27-
print(devops[2:5][0][5:11])
29+
print(devops[2:5][0][5:11]) # Script
2830
print(devops[2:5][0][5:11][-1])
2931
3032
# Slicing List
@@ -41,14 +43,16 @@
4143
print(devops[2:5][0][5:11])
4244
print(devops[2:5][0][5:11][-1])
4345
44-
46+
"""
4547
# Dictionary Example
46-
Skills = {"DevOps": ("AWS", "Jenkins", "Python", "Ansible"), "Development": ["Java", "NodeJS", ".net"]}
47-
print(Skills)
48-
print(Skills["DevOps"])
49-
print(Skills["Development"])
48+
Skills = {
49+
"DevOps": ("AWS", "Jenkins", "Python", "Ansible"),
50+
"Development": ["Java", "NodeJS", ".net"]
51+
}
52+
print(Skills) # {'DevOps': ('AWS', 'Jenkins', 'Python', 'Ansible'), 'Development': ['Java', 'NodeJS', '.net']}
53+
print(Skills["DevOps"]) # ('AWS', 'Jenkins', 'Python', 'Ansible')
54+
print(Skills["Development"]) # ['Java', 'NodeJS', '.net']
5055

51-
print(Skills["DevOps"][-1])
52-
print(Skills["DevOps"][-1][:3])
56+
print(Skills["DevOps"][-1]) # Ansible
57+
print(Skills["DevOps"][-1][:3]) # Ans
5358

54-
"""

7_Operators.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,23 +59,23 @@
5959
6060
# Logical Operators
6161
62-
# and
63-
# or
64-
62+
# and - must be true
63+
# or - any one true
64+
'''
6565
a = 40
6666
b = 60
6767

6868
x = 2
6969
y = 3
70-
70+
print('* ' * 10)
7171
out = (a < b) or (x > y)
72-
print(out)
72+
print(out) # True
7373

7474
out = (a > b) or (x < y)
75-
print(out)
75+
print(out) # True
7676

7777
out = (a > b) or (x > y)
78-
print(out)
78+
print(out)
7979

8080
out = (a > b) and (x < y)
8181
print(out)
@@ -108,17 +108,23 @@
108108
result = a is not b
109109
print(result)
110110

111-
'''
112-
'''
111+
print('#' * 10)
112+
113113
a = 100
114114
p = a << 2
115+
print(p)
115116
p = a >> 2
116-
64 32 16 8 4 2 0
117-
1 1 0 0 1 0 0
118-
0 0 1 0 0 0 0 = 16
119-
0 0 1 1 0 0 1 = 24
117+
print(p)
118+
'''
119+
120+
256 128 64 32 16 8 4 2 1
121+
0 0 1 1 0 0 1 0 0 100
122+
1 1 0 0 1 0 0 0 0 100<<2 400(=256+128+16)
123+
0 0 0 0 1 1 0 0 1 100>>2 25 (=16+8+1)
124+
120125
121126
122127
z = 10 + 2 * 3 - 4 / 2 + 1
123128
print(z)
124-
'''
129+
'''
130+

8_0_Conditions.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
# IF Condition
2-
"""
2+
33
x = 21
44

55
if x < 30:
66
print("Inside IF block")
77
print("X is less than 30")
88

9-
print("Rest of the code.")
9+
print("Rest of the code.*****")
1010

1111
x = 31
1212

1313
if x < 30:
1414
print("Inside IF block")
1515
print("X is less than 30")
1616

17-
print("Rest of the code.")
17+
print("Rest of the code.####")
1818

1919

2020
# If/Else Condition
@@ -26,8 +26,8 @@
2626
else:
2727
print("Inside else block")
2828
print("x is greater than 30")
29+
print("Rest of the code.@@@")
2930

30-
"""
3131
# If/Elif/Else Condition
3232
x = 40
3333

8_1_Condition_vars.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
print("This IT Organization has various skill sets.")
66
print("Find out your match.")
77

8-
print("Enter Capitalised Values: ")
98

109
DevOps = ["Jenkins", "Ansible", "Bash", "Python", "Puppet", "Dockers", "Kubernetes", "Terraform"]
1110
Development = ("Nodejs", "Angularjs", "Java", ".net", "Python")
@@ -24,4 +23,4 @@
2423
print(f"We have contract employees with {usr_skill} skill.")
2524
else:
2625
print("Skill not found")
27-
print("Please check if you have entered value in capitalize or check the spelling.")
26+
print("Please check the spelling.")

9_0_Loops.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,31 @@
1111
for vac in VACCINES:
1212
print(f"{vac} vaccine provides Immunization against covid19")
1313
14+
print('*' *30)
15+
# Python program to show how the for loop works
16+
17+
# Creating a sequence which is a tuple of numbers
18+
numbers = [4, 2, 6, 7, 3, 5, 8, 10, 6, 1, 9, 2]
19+
20+
# variable to store the square of the number
21+
square = 0
22+
23+
# Creating an empty list
24+
squares = []
25+
26+
# Creating a for loop
27+
for value in numbers:
28+
square = value ** 2
29+
squares.append(square)
30+
31+
print("The list of squares is", squares)
32+
1433
"""
1534
# While Loop
1635
x = 0
1736
while x <= 10:
1837
print("Value of X is:", x)
1938
print("Looping")
20-
x+=1
39+
x=x+1
2140

22-
print("Rest of the code.")
41+
print("Rest of the code.")

0 commit comments

Comments
 (0)