From cae23805a760ed27cc6a98626fdd252ac0abcb46 Mon Sep 17 00:00:00 2001 From: Sendy Ramadhan Date: Tue, 19 Nov 2019 11:50:16 +0700 Subject: [PATCH 01/10] Create course1.py --- sendyram/course1.py | 49 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 sendyram/course1.py diff --git a/sendyram/course1.py b/sendyram/course1.py new file mode 100644 index 0000000..be2d0f1 --- /dev/null +++ b/sendyram/course1.py @@ -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)) \ No newline at end of file From 9cf4fed2314d112285dcbd0077e86faefadf8eb0 Mon Sep 17 00:00:00 2001 From: Sendy Ramadhan Date: Tue, 19 Nov 2019 21:07:13 +0700 Subject: [PATCH 02/10] Create dictionary.py --- sendyram/dictionary.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 sendyram/dictionary.py diff --git a/sendyram/dictionary.py b/sendyram/dictionary.py new file mode 100644 index 0000000..24fdb72 --- /dev/null +++ b/sendyram/dictionary.py @@ -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) \ No newline at end of file From f188bd1ce90478e65bea21b339de8605db5d2679 Mon Sep 17 00:00:00 2001 From: Sendy Ramadhan Date: Tue, 19 Nov 2019 21:07:18 +0700 Subject: [PATCH 03/10] Create list.py --- sendyram/list.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 sendyram/list.py diff --git a/sendyram/list.py b/sendyram/list.py new file mode 100644 index 0000000..c443255 --- /dev/null +++ b/sendyram/list.py @@ -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) \ No newline at end of file From 6c611ffd6b4bdb5060c2d8921b7c9bc4a63256e5 Mon Sep 17 00:00:00 2001 From: Sendy Ramadhan Date: Tue, 19 Nov 2019 21:07:22 +0700 Subject: [PATCH 04/10] Create list2d.py --- sendyram/list2d.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 sendyram/list2d.py diff --git a/sendyram/list2d.py b/sendyram/list2d.py new file mode 100644 index 0000000..825ddd9 --- /dev/null +++ b/sendyram/list2d.py @@ -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() \ No newline at end of file From 312481407f3b4864b62eca485491c7efc88f43e5 Mon Sep 17 00:00:00 2001 From: Sendy Ramadhan Date: Tue, 19 Nov 2019 21:07:26 +0700 Subject: [PATCH 05/10] Create list_comprehension.py --- sendyram/list_comprehension.py | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 sendyram/list_comprehension.py diff --git a/sendyram/list_comprehension.py b/sendyram/list_comprehension.py new file mode 100644 index 0000000..61ded31 --- /dev/null +++ b/sendyram/list_comprehension.py @@ -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) \ No newline at end of file From beaa750b773c808072c94f1ea28f69c0946bf085 Mon Sep 17 00:00:00 2001 From: Sendy Ramadhan Date: Tue, 19 Nov 2019 21:07:31 +0700 Subject: [PATCH 06/10] Create list_loop.py --- sendyram/list_loop.py | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 sendyram/list_loop.py diff --git a/sendyram/list_loop.py b/sendyram/list_loop.py new file mode 100644 index 0000000..083a626 --- /dev/null +++ b/sendyram/list_loop.py @@ -0,0 +1,3 @@ +students = ["Sendy", "Rizky", "Farhan", "Aras"] +for student in students: + print(student) \ No newline at end of file From 9326265d7f3097cd74625ef66c7eb582c0e463a1 Mon Sep 17 00:00:00 2001 From: Sendy Ramadhan Date: Tue, 19 Nov 2019 21:07:36 +0700 Subject: [PATCH 07/10] Create list_method.py --- sendyram/list_method.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 sendyram/list_method.py diff --git a/sendyram/list_method.py b/sendyram/list_method.py new file mode 100644 index 0000000..7188a4d --- /dev/null +++ b/sendyram/list_method.py @@ -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) \ No newline at end of file From abf5f179467d37fa8f878bed467bf5e2afd511e1 Mon Sep 17 00:00:00 2001 From: Sendy Ramadhan Date: Tue, 19 Nov 2019 21:07:38 +0700 Subject: [PATCH 08/10] Create tuple.py --- sendyram/tuple.py | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 sendyram/tuple.py diff --git a/sendyram/tuple.py b/sendyram/tuple.py new file mode 100644 index 0000000..1271288 --- /dev/null +++ b/sendyram/tuple.py @@ -0,0 +1,2 @@ +my_tuple = tuple(["box", "blue"]) +print(my_tuple) \ No newline at end of file From 232371641bd37ab98c462107bdaffbd0cda425f1 Mon Sep 17 00:00:00 2001 From: Sendy Ramadhan Date: Tue, 19 Nov 2019 21:07:41 +0700 Subject: [PATCH 09/10] Create tuple_immutable.py --- sendyram/tuple_immutable.py | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 sendyram/tuple_immutable.py diff --git a/sendyram/tuple_immutable.py b/sendyram/tuple_immutable.py new file mode 100644 index 0000000..63579f9 --- /dev/null +++ b/sendyram/tuple_immutable.py @@ -0,0 +1,3 @@ +tuple = ('box', 'blue', 'green') + +tuple[0] = 'box' \ No newline at end of file From 36f04b607ca924b1d0dc7d2e044b518c56a7deef Mon Sep 17 00:00:00 2001 From: Sendy Ramadhan Date: Tue, 19 Nov 2019 21:07:44 +0700 Subject: [PATCH 10/10] Create tuple_pack_unpack.py --- sendyram/tuple_pack_unpack.py | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 sendyram/tuple_pack_unpack.py diff --git a/sendyram/tuple_pack_unpack.py b/sendyram/tuple_pack_unpack.py new file mode 100644 index 0000000..902ee44 --- /dev/null +++ b/sendyram/tuple_pack_unpack.py @@ -0,0 +1,5 @@ +pair = ("lion", "whale") +(key, value) = pair + +print(key) +print(value) \ No newline at end of file