```python= import random n = int(input("start:")) m = int(input("finish:")) print(random.randint(n, m)) ``` # Q 1 Your classmates asked you to copy some paperwork for them. You know that there are 'n' classmates and the paperwork has 'm' pages. Your task is to calculate how many blank pages do you need. Example: Note: if n < 0 or m < 0 return 0! Waiting for translations and Feedback! Thanks! a=25 b=30 temen ada 3 kertas ada 6 teman kali kertas ```python= #dodo teman=6 paperwork=8 blankpaper=teman*paperworks print(blankpaper) ``` # Q 2 Clock shows h hours, m minutes and s seconds after midnight. Your task is to write a function which returns the time in milliseconds. Example: h = 0 m = 1 s = 1 result = 61000 rules: 0 <= h <= 23 0 <= m <= 59 0 <= s <= 59 ``` #note jam=10 menit=10 detik=11 10jam=36000 10menit=600 11detik=11 total=36611000 detik dikali 1000 menit dikali 60000 jam dikali 3600000 semua ditambah ``` ```python= #Q2 ``` --- # Q 3 You are required to create a simple calculator that returns the result of addition, subtraction, multiplication or division of two numbers. Your function will accept three arguments: The first and second argument should be numbers. The third argument should represent a sign indicating the operation to perform on these two numbers. if the variables are not numbers or the sign does not belong to the list above a message "unknown value" must be returned. Example: ``` calculator(1, 2, "+"); // 3 calculator(1, 2, "&"); // "unknown value" calculator(1, "k", "*"); // "unknown value" ``` Good luck! ```python= #Q3 #disini def calculator(a,b,c): d=a+b-c return d firstnumber=int(input("Please enter a number:")) secondnumber=int(input("Please enter a number:")) sign=input("please input a sign:") print(calculator(firstnumber,secondnumber,sign)) print(calculator(secondnumber,firstnumber,sign)) print(calculator(firstnumber,sign,secondnumber)) if sign.isdigit() print("stupid") ``` ``` def plus there was first and second third = first + second print third def minus there was first and second third = first - second print third def multiply there was first and second third = first * second print third def divide there was first and second third = first / second print third input first input second input sign if first is number and second is number if sign is plus call plus elif sign is minus call minus elif sign is star call multiply elif sign is slash call divide else print unknown value else print unknown value ``` ``` make a def there was first, second, and sign if first is number and second is number if sign is plus first + second elif sign is minus first - second elif sign is star first * second elif sign is slash first / second else unknown value else unknown value `` input first input second input sign print def with first, second, and sign ``` ada 3 argumen argumen 1, 2= angka argumen 3 =simbol kali,bagi,tambah,kurang def buat bikin rumus # note: OR 1 || 1 = 1 1 || 0 = 1 0 || 1 = 1 0 || 0 = 0 AND 1 && 1 = 1 1 && 0 = 0 0 && 1 = 0 0 && 0 = 0 NOT 0 = 1 1 = 0 ```python= def pi(): p = 3.14 q = p*p return p def lingkaran(r): pi = 3.14 bulat= pi * r**2 return bulat ``` ''' def calculator(a,b,c): if a.isdigit() and b.isdigit(): pass pertama=input("pertama:") kedua=input("kedua:") sign=input("please input a sign:") mangkokbaru=0 if sign=="+": mangkokbaru=pertama+kedua print(mangkokbaru) elif sign=="-": mangkokbaru=pertama-kedua print(mangkokbaru) elif sign=="*": mangkokbaru=pertama*kedua print(mangkokbaru) elif sign=="/": hasil=pertama/kedua print(mangkokbaru) else: print("Gabisa Tolol") ''' --- ```python= Data = [1,4,9,16,25,36,49,64] # mengakses list Subdata1 = Data[3] Subdata2 = Data[-3] # memotong list Subdata3 = Data[2:4] Subdata4 = Data[:4] Data2 = [100,200,300,400,500,600,700,800] # menambah list Data3 = Data + Data2 # merubah content dari list Data[4] = 87 # Mengcopy list ke variable baru a = Data[:] a[7] = 87 # merubah content list dengan menggunakan metoda slicing Data[3:5] = [11,12] # List dalam list x = [Data,Data2] # mengakses list dalam multidimensional list y = x[1][4] # methods untuk list Data.append(30) # Function yang bisa kita gunakan kepada list panjang_list = len(Data) print(Data) print(panjang_list) ``` ```python= names = [] moneys = [] noneys = [] # Set new_name to something other than 'quit'. new_name = '' new_money = 0 # Start a loop that will run until the user enters 'quit'. while new_name != 'n': # Ask the user for a name. new_name = input("Please tell me someone I should know, or enter 'n': ") # Add the new name to our list. if new_name != 'n': new_money = input("your money:") moneys.append(new_money) if new_money < 540000: new_money = new_money - 0 elif new_money > 540000 and new_money < 1210000: new_money = new_money - 37800 elif new_money > 1210001 and new_money < 2420000: new_money = new_money - 134600 elif new_money > 2420001 and new_money < 4530000: new_money = new_money - 376600 elif new_money > 4530001: new_money = new_money - 829600 names.append(new_name) noneys.append(new_money) # Show that the name has been added to the list. print("name") print(names) print(moneys) print(noneys) ```