You are on page 1of 6

JURUSAN TEKNOLOGI PERTANIAN

PROGRAM STUDI TEKNOLOGI REKAYASA KOMPUTER


PRAKTIK SISTEM OPERASI
SEMESTER III Process 200 menit x 2

no. Tanggal 4 November 2022 Revisi ke.

1. latihan I : Instalasi Thonny dan Geany IDE


Tahapan instalasi
a. Buka terminal
b. Ketik perintah berikut ini :

sudo apt update → masukkan password root masing – masing komputer, tunggu hingga 100%

sudo apt install thonny geany → perintah menginstall langsung instalasi aplikasi thonny IDE
dan geany IDE. Masukkan password root dan tunggu hingga
instalasi 100%

Setelah instalasi periksa Show Applications apakah editor sudah ada atau tidak. Gunakan salah satu
editor.

2. Latihan II : Pengenalan Thonny IDE

B
D

Perhatikan penjelasan materi, lalu jelaskan antar muka IDE diatas beserta fungsinya.
A……….
B………..
C……….
D………..
JURUSAN TEKNOLOGI PERTANIAN
PROGRAM STUDI TEKNOLOGI REKAYASA KOMPUTER
PRAKTIK SISTEM OPERASI
SEMESTER III Process 200 menit x 2

no. Tanggal 4 November 2022 Revisi ke.

3. Latihan II : Programming

Menggunakan shell pada Thonny IDE

a. hello_word.py

sentence = "Aku baru belajar program python dan baru sekali."


new_sentence = ""

index = 0

for word in sentence.split():

if index % 2 == 1:
new_sentence += "hello "
else:
new_sentence += word + " "

index += 1

# remove the last space at the end


sentence = sentence[:-1]

print(new_sentence)

Varibales Heap

Penjelasan program :

b. say_hello.py

def sentenceReplace(sentence):
sentence_list = sentence.split()
for counter, word in enumerate(sentence_list):
if counter % 2 == 0:
sentence_list[counter] = "Hello"
new_sentence = " ".join(sentence_list)
print(new_sentence)

sentenceReplace(input("Say Something here!"))


JURUSAN TEKNOLOGI PERTANIAN
PROGRAM STUDI TEKNOLOGI REKAYASA KOMPUTER
PRAKTIK SISTEM OPERASI
SEMESTER III Process 200 menit x 2

no. Tanggal 4 November 2022 Revisi ke.

Varibales Heap

Penjelasan program :

c. switch_case_statement.py

def job_details(ID):
switcher = {
"100": "Job Description: Software Engineer",
"200": "Job Description: Lawyer",
"300": "Job Description: Graphics Designer",
}
'''The first argument will be returned if the match found and
nothing will be returned if no match found'''

return switcher.get(ID, "nothing")

# Take the job ID


job_id = input("Enter the job ID: ")
# Print the output
print(job_details(job_id))

Varibales Heap

Penjelasan program :
JURUSAN TEKNOLOGI PERTANIAN
PROGRAM STUDI TEKNOLOGI REKAYASA KOMPUTER
PRAKTIK SISTEM OPERASI
SEMESTER III Process 200 menit x 2

no. Tanggal 4 November 2022 Revisi ke.

d. calc.py

# Program make a simple calculator

# This function adds two numbers


def add(x, y):
return x + y

# This function subtracts two numbers


def subtract(x, y):
return x - y

# This function multiplies two numbers


def multiply(x, y):
return x * y

# This function divides two numbers


def divide(x, y):
return x / y

print("Select operation.")
print("1.Add")
print("2.Subtract")
print("3.Multiply")
print("4.Divide")

while True:
# take input from the user
choice = input("Enter choice(1/2/3/4): ")

# check if choice is one of the four options


if choice in ('1', '2', '3', '4'):
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))

if choice == '1':
print(num1, "+", num2, "=", add(num1, num2))

elif choice == '2':


print(num1, "-", num2, "=", subtract(num1, num2))

elif choice == '3':


print(num1, "*", num2, "=", multiply(num1, num2))

elif choice == '4':


print(num1, "/", num2, "=", divide(num1, num2))

# check if user wants another calculation


# break the while loop if answer is no
next_calculation = input("Let's do next calculation? (yes/no): ")
if next_calculation == "no":
break

else:
print("Invalid Input")
JURUSAN TEKNOLOGI PERTANIAN
PROGRAM STUDI TEKNOLOGI REKAYASA KOMPUTER
PRAKTIK SISTEM OPERASI
SEMESTER III Process 200 menit x 2

no. Tanggal 4 November 2022 Revisi ke.

Varibales Heap

Penjelasan program :

e. calc_panjang.py

import tkinter as tk
import tkinter.messagebox
from tkinter.constants import SUNKEN

window = tk.Tk()
window.title('Program Kalkulator')
frame = tk.Frame(master=window, bg="skyblue", padx=10)
frame.pack()
entry = tk.Entry(master=frame, relief=SUNKEN, borderwidth=3, width=30)
entry.grid(row=0, column=0, columnspan=3, ipady=2, pady=2)

def myclick(number):
entry.insert(tk.END, number)

def equal():
try:
y = str(eval(entry.get()))
entry.delete(0, tk.END)
entry.insert(0, y)
except:
tkinter.messagebox.showinfo("Error", "Syntax Error")

def clear():
entry.delete(0, tk.END)

button_1 = tk.Button(master=frame, text='1', padx=15,


pady=5, width=3, command=lambda: myclick(1))
button_1.grid(row=1, column=0, pady=2)
button_2 = tk.Button(master=frame, text='2', padx=15,
pady=5, width=3, command=lambda: myclick(2))
button_2.grid(row=1, column=1, pady=2)
button_3 = tk.Button(master=frame, text='3', padx=15,
pady=5, width=3, command=lambda: myclick(3))
JURUSAN TEKNOLOGI PERTANIAN
PROGRAM STUDI TEKNOLOGI REKAYASA KOMPUTER
PRAKTIK SISTEM OPERASI
SEMESTER III Process 200 menit x 2

no. Tanggal 4 November 2022 Revisi ke.

button_3.grid(row=1, column=2, pady=2)


button_4 = tk.Button(master=frame, text='4', padx=15,
pady=5, width=3, command=lambda: myclick(4))
button_4.grid(row=2, column=0, pady=2)
button_5 = tk.Button(master=frame, text='5', padx=15,
pady=5, width=3, command=lambda: myclick(5))
button_5.grid(row=2, column=1, pady=2)
button_6 = tk.Button(master=frame, text='6', padx=15,
pady=5, width=3, command=lambda: myclick(6))
button_6.grid(row=2, column=2, pady=2)
button_7 = tk.Button(master=frame, text='7', padx=15,
pady=5, width=3, command=lambda: myclick(7))
button_7.grid(row=3, column=0, pady=2)
button_8 = tk.Button(master=frame, text='8', padx=15,
pady=5, width=3, command=lambda: myclick(8))
button_8.grid(row=3, column=1, pady=2)
button_9 = tk.Button(master=frame, text='9', padx=15,
pady=5, width=3, command=lambda: myclick(9))
button_9.grid(row=3, column=2, pady=2)
button_0 = tk.Button(master=frame, text='0', padx=15,
pady=5, width=3, command=lambda: myclick(0))
button_0.grid(row=4, column=1, pady=2)

button_add = tk.Button(master=frame, text="+", padx=15,


pady=5, width=3, command=lambda: myclick('+'))
button_add.grid(row=5, column=0, pady=2)

button_subtract = tk.Button(
master=frame, text="-", padx=15, pady=5, width=3, command=lambda: myclick('-'))
button_subtract.grid(row=5, column=1, pady=2)

button_multiply = tk.Button(
master=frame, text="*", padx=15, pady=5, width=3, command=lambda: myclick('*'))
button_multiply.grid(row=5, column=2, pady=2)

button_div = tk.Button(master=frame, text="/", padx=15,


pady=5, width=3, command=lambda: myclick('/'))
button_div.grid(row=6, column=0, pady=2)

button_clear = tk.Button(master=frame, text="clear",


padx=15, pady=5, width=12, command=clear)
button_clear.grid(row=6, column=1, columnspan=2, pady=2)

button_equal = tk.Button(master=frame, text="=", padx=15,


pady=5, width=9, command=equal)
button_equal.grid(row=7, column=0, columnspan=3, pady=2)

window.mainloop()

variables dan Heap banyak, dibuat dan ditulis dibelakang kertas print labsheet.

You might also like