Nama : Putri Amelia
NIM : 240907501022
No : 19
[ ]
print ('hai uti')
hai uti
[ ]
print ('jual pulsa')
jual pulsa
Klik dua kali (atau tekan Enter) untuk mengedit
[ ]
print ('he looks gorgeous')
he looks gorgeous
[ ]
print ('bye') # komentar
bye
[ ]
from google.colab import drive
drive.mount('/content/drive')
[ ]
print ('ecacanti') #apa
ecacanti
[ ]
help ('keywords')
Here is a list of the Python keywords. Enter any keyword to get more help.
False class from or
None continue global pass
True def if raise
and del import return
as elif in try
assert else is while
async except lambda with
await finally nonlocal yield
break for not
[ ]
help ('break')
The "break" statement
*********************
break_stmt ::= "break"
"break" may only occur syntactically nested in a "for" or "while"
loop, but not nested in a function or class definition within that
loop.
It terminates the nearest enclosing loop, skipping the optional "else"
clause if the loop has one.
If a "for" loop is terminated by "break", the loop control target
keeps its current value.
When "break" passes control out of a "try" statement with a "finally"
clause, that "finally" clause is executed before really leaving the
loop.
Related help topics: while, for
[ ]
2var = 'aco'
print (2var)
[ ]
myvar = 'huruf'
my_var = 'huruf dan underscore'
_my_ami = 'underscore dan huruf'
myVAR = 'buci'
MYAMI = 'TOLA'
MUTI3 = 'huruf kapital dan angka'
u2 = 'uti'
[ ]
#myvar = 'huruf' 'memperbaiki'
[ ]
x = 3
y = '3'
[ ]
help ('lambda') # contoh keywords
Lambdas
*******
lambda_expr ::= "lambda" [parameter_list] ":" expression
Lambda expressions (sometimes called lambda forms) are used to create
anonymous functions. The expression "lambda parameters: expression"
yields a function object. The unnamed object behaves like a function
object defined with:
def <lambda>(parameters):
return expression
See section Function definitions for the syntax of parameter lists.
Note that functions created with lambda expressions cannot contain
statements or annotations.
Related help topics: FUNCTIONS
[ ]
#legal
mycookie = 'huruf'
my_cookie = 'huruf dan underscore'
_my_cookie = 'underscore dan huruf'
myCookie = 'ipi'
MYCOOKIE = 'ipi'
mycookie12 = 'huruf dan angka'
u2 = 'cipinong'
print(_my_cookie)
#print('nama:', u2)
underscore dan huruf
[ ]
#ilegal
# 12mycookie = 'dimulai dengan angka'
# my-cookie = 'cookie dipisahkan dengan DASH'
# my cookie = 'cookie dipisahkan dengan spasi'
#print(my-cookie)
[ ]
"""
1. variabel dan tipe data #string
"""
# deklarasi variabel
a = "** aku mau makan dimsum **"
print(a)
print('------------------------')
#2. multiple variable
x, y, z = "aku", " bisa", " moshing"
print(x)
print(y)
print(z)
print('-----------------')
# re-declaration of variables:
a = "uti bisa"
print(a+z)
** aku mau makan dimsum **
------------------------
aku
bisa
moshing
-----------------
uti bisa moshing
[ ]
print(nama_lengkap, '(' + usia + ')', ',', 'dari', alamat, ', kata mutiara:',
kata_mutiara)
print('\nTipe dari nama_lengkap:', type(nama_lengkap))
print('Tipe dari usia:')
print('Tipe dari alamat:')
print('Tipe dari kata_mutiara:')
putri data (12) , dari ambon , kata mutiara: it's okay to not be okay
Tipe dari nama_lengkap: <class 'str'>
Tipe dari usia:
Tipe dari alamat:
Tipe dari kata_mutiara:
"""
2. variable dan tipe data #numbers
"""
panjang = 5
lebar = 5.5
luas = panjang * lebar
print('luas:', panjang, '*', lebar, '=', luas)
print('Tipe dari variable panjang:', type(panjang))
print(' Tipe dari variable lebar:',)
print(' Tipe dari variable luas:', type(luas))
luas: 5 * 5.5 =27.5
Tipe dari variable panjang: <class 'int'>
Tipe dari variable lebar:
Tipe dari variable luas: <class 'float'>
# penjumlahan dua data integer
print('penjumlahan integer:', 20 + 5) # output 55
# 'penjumlahan' dua data string
print('penggabungan dua string:','2' + '5') # output 55
penjumlahan integer: 25
penggabungan dua string: 25
#3. contoh type boolean
saya_orang_indonesia = true
saya_adalah_spiderman = false
print('1. apakah saya orang Indonesia?', saya_orang_indonesia)
print('2. apakah saya adalah spiderman?', saya_adalah_spiderman)
print('3. Tipe dari saya_orang_indonesia', type(saya_orang_indonesia))
print('4. Tipe dari saya_adalah_spiderman', type(saya_adalah_robot))