Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Faiha Lesson 2
#python 3.5.2 # https://1drv.ms/f/s!ArsHV2FdZgQ1iQOclKKq2kqbxLdg # Loops - For Loops x = [1, 2, 7, 9, 10, 3, 14] y = [] # x and y are lists # Exercise 1 # ------------- # 1. Create a list of numbers. 2. Compute the squares for each number in the list. 3. Then print the list. q = [] m = [] for each_n in range(1, 20, 3): q.append(each_n) # my list of numbers m.append(each_n*each_n) # my list of numbers squared #print ("q = ", q) #print ("m = ", m) # Exercise 2 # ------------- # Create a list of 20 numbers - [1,20]. If the number is even, print "Even". If the number is odd, print "Odd". # [modulo operation] if number%2 == 0: then even, elif number%2 == 1, then odd. for each_i in range (20): if each_i%2 == 0: pass #print ( each_i, 'is even.') elif each_i%2 == 1: pass #print ( each_i, 'is odd.') # Exercise 3 # ------------- # while condition is true: # keep doing something # (have something that will change the condition later) count = 0 while count < 5: print (count) count = count + 1 # count increased its value by 1 # Exercise 4 # --------------- # Use a while/for loop to print this diagram. You will need to use if conditions also. # * # ** # *** # ****
run
|
edit
|
history
|
help
0
linked_lists
Lesson 5
RNG
Infinite Fibonacci generator
Q1
Python3 - product lists
Prueba
Gh
Atur cara mengira luas dan isipadu sebuah trapezium
Phython