Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions sendyram/course1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
def test_conditional():
name = "Sendy"

if(name == "Sendy"):
print("this is if")
elif(name == "Domu"):
print("this is elif")
else:
print("this is else")

def test_looping():
for x in range(0,5):
print("nilai x",x)

i = 0
while(i<5):
print("nilai i", i)

#print(test_looping())

global_var = 10
def test_namespace():
private_var = 15
print("private var = ",private_var)
print("global var = ",global_var)

print(test_namespace())

def test_string_operator():
full_string = "this is full string"
temp_string = "temp string"
upper_string = "this is upper"
lower_string = "this is lower"

print(full_string+temp_string)
print(full_string[3:6])
print(upper_string.lower())
print(lower_string.upper())
print(len(full_string))
print(full_string.strip('t'))
print(full_string.replace("full","some"))
print(full_string.split(" "))

test_string_operator()

def test_function(value):
return value;

print(test_function(4))
14 changes: 14 additions & 0 deletions sendyram/dictionary.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class kucing:
def __init__(__args__):
pass


animal = {}
animal["lion"] = 10
animal["whale"] = 30
animal[1] = "whale"

you = kucing()
animal[you] = 1

print(animal)
13 changes: 13 additions & 0 deletions sendyram/list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
list = []

list.append(1)
list.append(2)
list.append(3)

list.append(("Sendy", "Gugu"))

plants = {}
plants["durian"] = 23
list.append(plants)

print(list)
14 changes: 14 additions & 0 deletions sendyram/list2d.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
list2d = []
list2d.append([])
list2d.append([])

list2d[0].append(1)
list2d[0].append(2)

list2d[1].append("Simpang")
list2d[1].append("Dogan")

for y in list2d:
for x in y:
print(x, end=" ")
print()
7 changes: 7 additions & 0 deletions sendyram/list_comprehension.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
numbers = [1, 2, 3]

multiply100 = [number * 10 for number in numbers]
print(multiply100)

result = [number * 100 for number in numbers]
print(result)
3 changes: 3 additions & 0 deletions sendyram/list_loop.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
students = ["Sendy", "Rizky", "Farhan", "Aras"]
for student in students:
print(student)
19 changes: 19 additions & 0 deletions sendyram/list_method.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
students = ["Sendy"]
students.append("Ramadhan")
print(students)

students.insert(1, "D")
print(students)

woman_students = ["Runu", "Rana", "Rini", "Rono"]
students.extend(woman_students[0:4])
print(students)

students.sort()
print(students)

students.reverse()
print(students)

students.remove("Ramadhan")
print(students)
2 changes: 2 additions & 0 deletions sendyram/tuple.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
my_tuple = tuple(["box", "blue"])
print(my_tuple)
3 changes: 3 additions & 0 deletions sendyram/tuple_immutable.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tuple = ('box', 'blue', 'green')

tuple[0] = 'box'
5 changes: 5 additions & 0 deletions sendyram/tuple_pack_unpack.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pair = ("lion", "whale")
(key, value) = pair

print(key)
print(value)