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

task BasicCourse Prayogi #8

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Prayoginotonegoro
Copy link

@Prayoginotonegoro Prayoginotonegoro commented Nov 8, 2019

Single Line

# this is a single line comment.

Multi Line

'''
this is a multiline
comment.
'''

How to declare variables

a = 'some text' # declare a string variable
b = 123         # an integer
c = True        # a boolean

Input User

input("Nama ku Adalah : ")

###Looping For

def Looping():
    for i in range (1,5):
        print("nilai i : ", i)      
Looping()

Global Variabel

globalVar = 5
def testName():
    privateVar = 1
    globalVar = 2
    print("Privat Variable : ", privateVar)
    print("Global Variable : ", globalVar)
testName()
print("Global Variable 2 : ", globalVar)

String Operator

def testStringOperator():
    fullString = "this is full string"
    tempString = "temp string"
    upperString = "THIS IS UPPER"
    lowerString = "this is lower"
    print(fullString + tempString) #concanation
    print(fullString[3:7]) #print karakter antara kurang dari 3 dan kurang dari 7
    print(upperString.lower())
    print(lowerString.upper())
    print("len : ", len(fullString))
    print(fullString.strip("t"))
    print(fullString.replace("full", "some"))
    print(fullString.split("is"))
testStringOperator()

While Looping

def whileLoop():
    x = 1
    while x < 5:
        print(x)
        x+=1
whileLoop()

Cara Membuat Fungsi pada Python

def nama_fungsi():
    print "Hello ini Fungsi"

Membuat fungsi dengan parameter

def luas_segitiga(alas, tinggi):
    luas = (alas * tinggi) / 2
    print "Luas segitiga: %f" % luas;
luas_segitiga(4, 6) # Pemanggilan fungsi

fungsi untuk menampilkan semua data

def show_data():
    if len(buku) <= 0:
        print "BELUM ADA DATA"
    else:
        for indeks in range(len(buku)):
            print "[%d] %s" % (indeks, buku[indeks])

fungsi untuk menambah data

def insert_data():
    buku_baru = raw_input("Judul Buku: ")
    buku.append(buku_baru)

fungsi untuk edit data

def edit_data():
    show_data()
    indeks = input("Inputkan ID buku: ")
    if(indeks > len(buku)):
        print "ID salah"
    else:
        judul_baru = raw_input("Judul baru: ")
        buku[indeks] = judul_baru

fungsi untuk menhapus data

def delete_data():
    show_data()
    indeks = input("Inputkan ID buku: ")
    if(indeks > len(buku)):
        print "ID salah"
    else:
        buku.remove(buku[indeks])

Fungsi Membaca File Perbaris di python

# buka file
file_puisi = open("puisi.txt", "r")
# baca isi file
print file_puisi.readlines()
# tutup file
file_puisi.close()

@Prayoginotonegoro Prayoginotonegoro changed the title readme.md task BasicCourse Prayogi Nov 8, 2019
README.md Outdated Show resolved Hide resolved
@ariefrahmansyah
Copy link
Member

Yog, ada merge conflict nih. Tolong resolve dulu ya. Coba cek di sini: https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/resolving-a-merge-conflict-on-github

Copy link
Member

@ariefrahmansyah ariefrahmansyah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yog, tolong masukin ke folder kamu ya file-file python kamu

@Prayoginotonegoro
Copy link
Author

yog, tolong masukin ke folder kamu ya file-file python kamu

Oke kk nanti akan aku masukkan file python aku .

@ariefrahmansyah
Copy link
Member

Yog, sorry. I just updated README.md, so this PR has merge conflict again 😅
Please resolve it again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants