-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstrings.py
More file actions
68 lines (56 loc) · 1.4 KB
/
Copy pathstrings.py
File metadata and controls
68 lines (56 loc) · 1.4 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
str = str()
print(str)
# s1 = input("Enter first string: ")
# s2 = input("Enter second string: ")
# if s1 % 2 == 0:
# print("First string has even length.")
# else:
# print("First string has Odd length.")
s = "string"
print(s[2])
print(s[-2])
print(s[0:3])
text = "This is Text"
if "is" not in text:
print("is not present")
else:
print("is present")
anotherText = " Fruits is blah blah "
x = anotherText.strip()
print(x)
y = anotherText.lstrip()
print(y)
z = anotherText.rstrip()
print(z)
try:
number = int(input("Enter a number: "))
result = 10 / number
except ValueError:
print("Error: Invalid input. Please enter an integer.")
except ZeroDivisionError:
print("Error: Cannot divide by zero.")
try:
number = int(input("Enter a number: "))
result = 10 / number
except (ValueError, ZeroDivisionError):
print("Error: Invalid input or division by zero.")
else:
print(f"Result is: {result}")
try:
number = int(input("Enter a number: "))
result = 10 / number
except (ValueError, ZeroDivisionError):
print("Error: Invalid input or division by zero.")
else:
print(f"Result is: {result}")
finally:
print("Execution completed.")
try:
number = int(input("Enter number: "))
result = 10 / number
except(ValueError, ZeroDivisionError):
print("Vlaue must be greater than zero and integer")
else:
print(result)
finally:
print("Program complete")