-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathslices.py
More file actions
85 lines (68 loc) · 2.3 KB
/
Copy pathslices.py
File metadata and controls
85 lines (68 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#In the first line, print the third character of this string.
string1=input('enter the first string1=')
print(string1[2])
#In the second line, print the second to last character of this string.
string2=input("enter the second string2= ")
length2 = len(string2)
for i in range (1,length2):
print(string2[i])
#In the third line, print the first five characters of this string.
string3 = input('enter the string3=\n')
for j in range (0,4):
print(string3[j])
#In the fourth line, print all but the last two characters of this string.
string4 = input('enter the string4=')
length4 = len(string4)
for i in range (0,length4-2):
print(string4[i])
#In the fifth line, print all the characters of this string with even indices (remember indexing starts at 0, so the characters are displayed starting with the first).
string5 = input('enter the string5=')
length5 = len(string5)
for i in range (0,length5,2):
print(string5[i])
#In the sixth line, print all the characters of this string with odd indices (i.e. starting with the second character in the string).
string6 = input('enter the string6=')
length6 = len(string6)
for i in range (1,length6,2):
print(string6[i])
#In the seventh line, print all the characters of the string in reverse order.
string7 = input('enter the string7=')
length7 = len(string7)
for i in range (length7-1,-1,-1):
print(string7[i],end=" ")
print()
#pallindrome
string7 = input('enter the string=')
length7 = len(string7)
l = length7//2
for i in range (0,l):
if string7[i]==string7[length7-i-1]:
print('string is pallindrome')
break
else:
print('string is not pallindrome')
#In the eighth line, print every second character of the string in reverse order, starting from the last one.
string8 = input('enter the string8=')
length8 = len(string8)
for i in range (length8-1,0,-1):
print(string8[i],end=" ")
print()
#In the ninth line, print the length of the given string.
string9 = input('enter the string9=')
count = 0
for ch in string9:
count +=1
print(count)
#to count the length of a number
string9 = input('enter the string9=')
number9 = int(string9)
count = 0
while number9 > 0:
number9 = number9 // 10
count += 1
print(count)
#myStyle code
number = int(input('enter the number10:'))
string10 = str(number)
l = len(string10)
print('length=',l)