-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpractice_generall.py
68 lines (54 loc) · 1.25 KB
/
practice_generall.py
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
name = "safwa"
age = "20"
str ="my name is {} of age {}"
print(str.format(name,age))
print(len(str))
a= "university"
print((a.upper()),a)
x = " BELONG TO FSD"
#if "BELONG" in x
print("yes , it is presnt")
x = "Hello"
y = 15
print(bool(x))
print(bool(y))
print(bool("Hello"))
print(bool(15))
print(bool(10<4))
x = 9
x%=2
print(x)
thislist = [ "cherry", "apple","apple", "banana"]
print(type(thislist))
print(len(thislist), thislist)
list1 = ["apple","banana"]
list2 = [1,2,3,4,5]
list3 = [True, False]
list4 =[1, 2, 'apple', 4]
print(list4)
thislist = list(("apple", "banana", "cherry")) # note the double round-brackets
print(thislist[-1])
#print("apple" in list4)/
if "apple" in list4:
print("Apple is present")
#
list1 = ["apple","banana"]
list1[0:1]=["cherry"]
print(list1)
thislist = ["apple", "banana", "cherry"]
thislist[1:3] = ["watermelon"]
print(thislist)
# to insert value in array
list = ["apple", "banana", "cherry"]
list.insert(2, "watermelon")
print(list)
thislist1 = ["apple", "banana", "cherry"]
thislist1.append("orange")
print(thislist1)
thislist2 = ["apple", "banana", "cherry"]
thislist2.extend("tropical")
print(thislist2)
thislist3 = ["apple", "banana", "cherry"]
thistuple = ("kiwi", "orange")
thislist3.extend(thistuple)
print(thislist3)