Python_6

Run Settings
LanguagePython
Language Version
Run Command
#FOR LOOPS #for variable we create in something/iterable: # for item in [1,2,3,4,5]: # for x in ['a', 'b', 'c']: # print(item,x) # #iterable -> it is an object that iterated(one by one check each item in the collection) # user = { # 'name':'JOJO', # 'age':2000, # 'can_swim':False # } # for key, value in user.items(): # print(key, value) #Exercise # my_list = [1,2,3,4,5,6,7,8,9,10] #count # counter = 0 # for item in my_list: # counter = counter + item # print(counter) #range range(start, end, step) # for number in range(2): # print(list(range(10))) #enumerate # for i,char in enumerate(list(range(100))): # if char == 50: # print(f'index of 50 is: {i}') #WHILE LOOPS #while condition: -> continues until the condition is met # print(something) # break # i = 0 # while i < 50: # print(i) # i +=1 # else: # print('All the work is done') # my_list = [1,2,3] # for item in my_list: # print(item) # i = 0 # while True: # response = input('say something: ') # if (response == 'bye'): # break #break, continue -> goes back to the top of the while/for loop, pass -> pass for now #Exercise #Display the image below to the right hand side where the 0 is going to be ' ', and the 1 is going to be '*'. This will reveal an image! picture = [ [0,0,0,1,0,0,0], [0,0,1,1,1,0,0], [0,1,1,1,1,1,0], [1,1,1,1,1,1,1], [0,0,0,1,0,0,0], [0,0,0,1,0,0,0] ] fill = '*' empty = ' ' for image in picture: for x in image: if x: print(fill, end = ' ') else: print(empty, end = ' ' ) print('')
Editor Settings
Theme
Key bindings
Full width
Lines