Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

course_week#1 #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
92 changes: 92 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,95 @@ a = 'some text' # declare a string variable
b = 123 # an integer
c = True # a boolean
```
#Input User
input("Masukkan Nilai: ")

#If-else Condition
def test_condition():
name = "rizki"

if(name=="rizki"):
print("this is if")
elif(name=="rizka"):
print("this is elif")
else:
print("this is else")

#Looping for-each dan while
def test_looping():
for x in range (0,5):
print("nilai x: ",x)

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

def test_function_return_value(input_value):
return input_value * 2

#Global Variabel
global_var = 10
def test_namespace():
private_var = 5
global_var = 6

print("private val: ", private_var)
print("private val: ", global_var)

#String Operator
def test_string_operator():
full_string = "ini string normal"
temp_string = "string tambahan"
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("l"))
print(full_string.replace("ini", "itu"))
print(full_string.split(" "))

test_condition()
test_looping()
print(test_function_return_value(5))
test_string_operator()

# Membuat fungsi dengan parameter
def luas_persegipjg(panjang, lebar):
luas = panjang * lebar
print "Luas Persegi Panjang: %f" % luas;
luas_persegipjg(7, 4)

# Fungsi nilai boolean
# empty list
lis = []
print(lis,'is',bool(lis))

# empty tuple
t = ()
print(t,'is',bool(t))

# zero complex number
c = 0 + 0j
print(c,'is',bool(c))

num = 99
print(num, 'is', bool(num))

val = None
print(val,'is',bool(val))

val = True
print(val,'is',bool(val))

# empty string
str = ''
print(str,'is',bool(str))

str = 'Hello'
print(str,'is',bool(str)