Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
hw1
# Covered so far: # 1. Simple data types # 2. If conditions # 3. While/for loops # 4. Functions # 5. # def function_name(arg1, arg2, ..., argN): # do_something def add(input_list): total_sum = 0 for each_num in input_list: total_sum = total_sum + each_num return (total_sum) def multiply(input_list): multi_each = 1 for each_num in input_list: multi_each = multi_each* each_num return (multi_each) # MATLAB syntax # function [output] = function_name(arg1, arg2, ... , argN) # # end # total_sum each_num total_sum + each_num # 0 3 = 3 -> total_sum # 3 2 = 5 -> total_sum # 5 45 = 50 -> total_sum # Write a function that adds two numbers x_list = [7, 0] c=add(x_list) print (c) d = multiply([3, 1]) print(d) # Fibonacci sequence: [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ... ] # Homework: # 1. Print the Fibonacci sequence up to N # 2. Print a N-diamond for e.g. N = 5 # 5-shaped diamond # * # *** # ***** # *** # * # 7-shaped diamond # * # *** # ***** # ******* # ***** # *** # * # 3. Design the N-tree # N = 4 # @ # @@@ # @@@@@ # @@@@@@@ # |||
run
|
edit
|
history
|
help
0
Python My G(ame,uess)
Calculator
substring
(P3) Rok przestępny
ort
Lesson 2-ex
ms 80
Doki Doki Study Club p.one
Привет
Myone