Rabu, 07 Oktober 2020

Tugas Dasar Pemrograman Nabila

 

TUGAS 1
Buatlah 1 Contoh Operator Penugasan
Buatlah 1 Contoh Operator Logika
Buatlah 1 Contoh Operator Bitwise
Buatlah 1 Contoh Operator Identitas
Buatlah 1 Contoh Operator Keanggotaan



Jawab:
#Operator Penugasan

x= 15
print("nilai x")
print(x)

print("nilai x+=5")
x+=5
print(x)

print("nilai x-=5")
x-=5
print(x)

print("nilai x*=5")
x*=5
print(x)

print("nilai x/=5")
x/=5
print(x)

print("nilai x**=5")
x**=5
print(x)

print("nilai x//=5")
x//=5
print(x)

print("nilai x%=5")
x%=5
print(x)

Python File

Hasil Run


# Operator Logika

 

#operator AND

print("AND")

print(True and False)

print(True and True)

print(False and True)

print(False and False)

 

#operator OR

print("OR")

print(True or False)

print(True or True)

print(False or True)

print(False or False)

 

#operator NOT

print("NOT")

print(not True)

print(not False)

Python File

Hasil Run


#Operator Bitwise

 

a=10

b=5

 

#operator OR(|)

c=a|b

print("=========OR=========")

print("nilai:",a,",binary:",format(a,"08b"))

print("nilai:",b,",binary:",format(b,"08b"))

print("-------------------(|)")

print("nilai:",c,",binary:",format(c,"08b"))

 

 

#operator AND (&)

c=a&b

print("=========AND=========")

print("nilai:",a,",binary:",format(a,"08b"))

print("nilai:",b,",binary:",format(b,"08b"))

print("-------------------(&)")

print("nilai:",c,",binary:",format(c,"08b"))

Python File

Hasil Run





#Operator Identitas

 

a=4

b=4

c=6

 

#operator is

print("a is b=", a is b)

print("a is c=", a is c)

 

#operator is not

print("a is not b=", a is not b)

print("a is not c=", a is not c)

 Python File


Hasil Run


 

 

#Operator Keanggotaan

 

data1=("13","15","17")

 

#operator in

print("13 in data1=", "13" in data1)

print("14 in data1=", "14" in data1)

 

#operator not in

print("13 not in data1=", "13" not in data1)

print("14 not in data1=", "14" not in data1)


Python File


Hasil Run


 


TUGAS MEMBUAT PROGRAM


print("                          TOKO MAINAN ANAK")

print("                     **************************")

pembeli=input("Masukan Nama Pembeli : ")

kode=input("Masukan Kode Mainan : ")

harga=int(input("Masukan Harga : "))

jumbel=int(input("Masukan Jumlah Beli : "))

total=harga*jumlahbeli

print("================================================")

print("Nama Pembeli = ", pembeli)

print("Kode Kue     = ", kode)

print("Harga        = ", harga)

print("Jumlah Beli  = ", jumbel)

print("Total        = ", total)

 Python File



Hasil Run

 


Nama      : Nabila Ramadhanti
NIM        : 12200331
Kelas       : 12.1B.07



 

Tidak ada komentar: