forked from SamuelAbiodun-dev/C13-Python-Exercise
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
95 lines (64 loc) · 1.92 KB
/
main.py
File metadata and controls
95 lines (64 loc) · 1.92 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
86
87
88
89
90
91
92
93
94
95
# This is a sample Python script.
from random_test import FirstClass
# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
def print_hi(name):
# Use a breakpoint in the code line below to debug your script.
print(f'Hi, {name}') # Press Ctrl+F8 to toggle the breakpoint.
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
print_hi('PyCharm')
myAccount = FirstClass('Adeola', 34)
print(myAccount.get_name())
# See PyCharm help at https://www.jetbrains.com/help/pycharm/
'''
x = "Adewunmi"
print(type(x))
a = "ADEKUNLE adeola EMMANUEL"
def myfunc():
global a
a = "Adewunmi"
print(a.replace("A", "E")) # prints Edewunmi
myfunc()
print(a) # prints Adewunmi
def newfunc():
x = "AdeolA"
print(x.replace("A", "E")) # prints EdeolE
print(x.split("e")) # prints ['Ad', 'olA']
newfunc()
name = "Emmanuel"
cohort = "cohort 13"
detail = "my name is {} and I am in {}"
print(detail.format(name, cohort))
a = 95
b = 25
c = "{} is greater than {}"
if a > b:
print(c.format(a, b))
else:
print(c.format(b, a))
class myclass():
def __len__(self):
return 0
__len__(self) is a function that determines the length of what the class is returning.
myobj = myclass()
print(bool(myobj)) # prints false
thislist = ["ADEOLA", 10, "6.2"]
name, age, height = thislist
print(name) # prints ADEOLA
print(age) # prints 10
print(height) # prints 6.2
print(thislist) # prints ['ADEOLA', 10, '6.2']
print(type(thislist)) # prints <class 'list'>
thisnewlist = list(("adeola", "adewunmi", "daniel"))
print(thisnewlist) # prints ['adeola', 'adewunmi', 'daniel']
thislist = ["apple", "banana", "cherry"]
thislist[1:2] = ["blackcurrant", "watermelon", "mango"]
print(thislist)
'''
print(
'''
this is a longer string, so we \
split it over two lines
'''
)