Blog Archives

homework_on_defs_unsolved

# -*- coding: utf-8 -*- “”” fill up with the appropriate code the non completed lines @authors: katkaranikola stkarlos “”” # write a def that returns a list with the indices of the inserted list # that contains items which

Posted in Uncategorized

lesson9_17_ear_3

# -*- coding: utf-8 -*- “”” Examples of initializing a list with random numbers and processing it @authors: katkaranikola stkarlos “”” import random def create_list(num): l = [] for i in range(0,num): x = random.randint(1,15) l.append(x) print “your list is:

Posted in Uncategorized

lesson9_17_ear_2

# -*- coding: utf-8 -*- “”” Created on Thu May 18 14:21:59 2017 Simple Examples of defs with lists @authors: katkaranikola stkarlos “”” def max_listas(l): M = l[0] for i in range(1, len(l)): if l[i] > M: M = l[i]

Posted in Uncategorized

lesson9_17_ear_1

# -*- coding: utf-8 -*- “”” Examples of defs @authors: katkaranikola stkarlos “”” def add_lists(l1,l2): l =[] if len(l1) == len(l2): for i in range(0, len(l1)): l.append(l1[i] + l2[i]) else: print ‘wrong lists’ return l m = [1,2,3,4] n =

Posted in Uncategorized

homework_on_lists_solutions

# -*- coding: utf-8 -*- “”” @authors: katkaranikola stkarlos “”” # δημιουργήστε λίστα l που περιέχει όλους τους αριθμούς από το 1 έως το 30. l = [] for i in range(1,31): l.append(i) print l # δημιουργήστε λίστα m που

Posted in Uncategorized

lesson8_17_ear_3

# -*- coding: utf-8 -*- “”” @authors: katkaranikola stkarlos “”” l = [] for i in range(100,201): if i % 7 == 0: l.append(i) print l, len(l), sum(l) k = [] for i in range(0,len(l)): if l[i]**2 % 2 ==

Posted in Uncategorized

lesson8_17_ear_2

# -*- coding: utf-8 -*- “”” @authors: katkaranikola stkarlos “”” l = [] for i in range(1,301): if i % 3 == 0 and i % 4 == 2: l.append(i) print l, len(l), sum(l) # seperate items with odd and

Posted in Uncategorized

lesson8_17_ear_1

# -*- coding: utf-8 -*- “”” @authors: katkaranikola stkarlos “”” l = [] for i in range(0,100): if i % 6 == 0: l.append(i) print l # seperate items with odd and even index to different lists odd = []

Posted in Uncategorized

homework_on_lists_unsolved

# -*- coding: utf-8 -*- “”” @authors: katkaranikola stkarlos “”” # δημιουργήστε λίστα l που περιέχει όλους τους αριθμούς από το 1 έως το 30. # δημιουργήστε λίστα m που περιέχει μόνο τα στοιχεία της l που διαρούνται με το

Posted in Uncategorized

lesson7_17_ear_3

# -*- coding: utf-8 -*- “”” @authors: katkaranikola stkarlos “”” l = [] s = 0 for i in range(1,11): l.append(i**2) s = s + l[i-1] print l, s, sum(l) k = [] for i in range(0,len(l)): if l[i] %

Posted in Uncategorized