File tree 8 files changed +163
-2
lines changed
8 files changed +163
-2
lines changed Original file line number Diff line number Diff line change
1
+ # i=int(input("enter the number:"))
2
+ # while(i<=38):
3
+ # i=int(input("enter the number:"))
4
+ # print(i)
5
+
6
+ # print("done with the loop")
7
+ # count=5
8
+ # while(count>0):
9
+ # print(count)
10
+ # count=count-1
11
+ # else:
12
+ # print("I am inside else")
13
+ # for i in range(11):
14
+ # if(i==10):
15
+ # break
16
+ # print("5 X",i+1,"=",5*(i+1))
17
+ # print("Loop ko chorrr ke nikal gya ")
18
+
19
+ for i in range (12 ):
20
+ if (i == 10 ):
21
+ print ("skip the iteration" )
22
+ continue
23
+ print ("5 X" ,i + 1 ,"=" ,5 * (i + 1 ))
24
+
25
+
Original file line number Diff line number Diff line change 21
21
print ("The tpe of b is " ,type (b ))
22
22
print ("the typpe oof c is " ,type (c ))
23
23
print ("The type of d is " ,type (d ))
24
+ print ("The type of d is " ,type (d ))
Original file line number Diff line number Diff line change 18
18
names = "Vishal"
19
19
print (len (names ))
20
20
print (names [0 :4 ])# n-1 tk chlta h
21
- print (names [:4 ])# n-1 tk chlta h
21
+ print (names [:4 ])# n-1 tk chlta h SLICING
22
22
print (names [1 :4 ])# n-1 tk chlta h
23
- print (names [0 :- 3 ])# n-1 tk chlta h
23
+ print (names [0 :- 3 ])# len(names)-3 6-3=3 isliyee Vis bss print ho rha NEGATTIVE SLICING
Original file line number Diff line number Diff line change
1
+ a = "Vishalsingh kashyap!!!!!!!!!!!!" #Srings are immutable
2
+ print (len (a ))
3
+ print (a .upper ()) #turns all char into upper case
4
+ print (a .lower ()) #turns all char into upper case
5
+ print (a .rstrip ("!" )) #removes the symbols the trailing symbols\
6
+ print (a .replace ("Vishal" ,"Anja" ))
7
+ print (a .split (" " ))
8
+ str1 = "Welcome to the Console !!!"
9
+ print (str1 .endswith ("!!!" ))
10
+
11
+ str1 = "Welcome to the Console !!!"
12
+ print (str1 .endswith ("to" , 4 , 10 ))
13
+
14
+ str1 = "He's name is Dan. He is an honest man."
15
+ print (str1 .find ("ishh" ))
16
+ # print(str1.index("ishh"))
17
+
18
+ str1 = "WelcomeToTheConsole"
19
+ print (str1 .isalnum ())
20
+ str1 = "Welcome"
21
+ print (str1 .isalpha ())
22
+
23
+ str1 = "hello world"
24
+ print (str1 .islower ())
25
+
26
+ str1 = "We wish you a Merry Christmas\n "
27
+ print (str1 .isprintable ())
28
+ str1 = " " #using Spacebar
29
+ print (str1 .isspace ())
30
+ str2 = " " #using Tab
31
+ print (str2 .isspace ())
32
+
33
+ str1 = "World Health Organization"
34
+ print (str1 .istitle ())
35
+
36
+ str2 = "To kill a Mocking bird"
37
+ print (str2 .istitle ())
38
+
39
+ str1 = "Python is a Interpreted Language"
40
+ print (str1 .startswith ("Python" ))
41
+
42
+ str1 = "Python is a Interpreted Language"
43
+ print (str1 .swapcase ())
44
+
45
+ str1 = "His name is Dan. Dan is an honest man."
46
+ print (str1 .title ())
Original file line number Diff line number Diff line change
1
+ # a=int(input("Enter the age: "))
2
+ # if(a>18):
3
+ # print("You can drive")
4
+ # else:
5
+ # print("you cannot drive") #the space before print is the indentataion
6
+
7
+ # print("Wowwww this line always prints as it is not in loop")
8
+
9
+
10
+ num = int (input ("Enter the value of num: " ))
11
+ if (num < 0 ):
12
+ print ("Number is negative." )
13
+ elif (num == 0 ):
14
+ print ("Number is Zero." )
15
+ elif (num == 999 ):
16
+ print ("Number is Special." )
17
+ else :
18
+ print ("Number is positive." )
19
+
20
+ print ("I am happy now" )
21
+
22
+
23
+ num = int (input ("enter the number:" ))
24
+ if (num < 0 ):
25
+ print ("Number is negative." )
26
+ elif (num > 0 ):
27
+ if (num <= 10 ):
28
+ print ("Number is between 1-10" )
29
+ elif (num > 10 and num <= 20 ):
30
+ print ("Number is between 11-20" )
31
+ else :
32
+ print ("Number is greater than 20" )
33
+ else :
34
+ print ("Number is zero" )
Original file line number Diff line number Diff line change
1
+ #MATCH CASE STATENENTS
2
+ x = int (input ("Enter the value of x: " ))
3
+ # x is the variable to match
4
+ match x :
5
+ # if x is 0
6
+ case 0 :
7
+ print ("x is zero" )
8
+ # case with if-condition
9
+ case 4 :
10
+ print ("case is 4" )
11
+
12
+ case _ if x != 90 :
13
+ print (x , "is not 90" )
14
+ case _ if x != 80 :
15
+ print (x , "is not 80" )
16
+ case _:
17
+ print (x )
Original file line number Diff line number Diff line change
1
+ # # #FOR LOOP
2
+ # # names=["Vishal","Anja","Vkash","Anvi"]
3
+ # # for name in names:
4
+ # # print(name)
5
+ # # for i in name:
6
+ # # print(i)
7
+ # for k in range(1,9):
8
+ # print(k+1)
9
+
10
+ # for k in range(1,10000):
11
+
12
+ # print(k)
13
+ # for k in range(2,20,2):
14
+ # print(k)
15
+
16
+ # DO WHILE LOOP EMALUATION
17
+ # do{
18
+ # #loop body
19
+ # }
20
+ # while(condition):
21
+ i = 0
22
+ while True :
23
+ print (i )
24
+ i = i + 1
25
+ if (i % 100 == 0 ):
26
+ break
Original file line number Diff line number Diff line change
1
+ #Good morning message
2
+
3
+ import time
4
+
5
+ timestamp = time .strftime ('%H:%M:%S' )
6
+ print (timestamp )
7
+ timestamp1 = int (time .strftime ('%H' ))
8
+ print (timestamp1 )
9
+ if timestamp1 < 12 :
10
+ print ("Good mornings python" )
11
+ else :
12
+ print ("mornings ends" )
You can’t perform that action at this time.
0 commit comments