Blog Archives

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

lesson7_17_ear_2

# -*- coding: utf-8 -*- “”” @authors: katkaranikola stkarlos “”” l = [] for i in range(1,6): x = raw_input(‘ dose arithmo: ‘) l.append(float(x)) print l, sum(l) m = [] for i in range(1,6): i = i – 1 if

Posted in Uncategorized

lesson7_17_ear_1

# -*- coding: utf-8 -*- “”” @authors: katkaranikola stkarlos “”” l = [] s = ‘anaconda’ l = list(s) print l print l[0] , l[-1] , len(l) #s[0] = ‘A’ #immutable leads to an error l[0] = ‘A’ #mutable print

Posted in Uncategorized

lesson6_17_ear_3

# -*- coding: utf-8 -*- “”” fill up with the appropriate code the non completed lines @authors: katkaranikola stkarlos “”” #compute the S1 = 1 + 12 + 23 + …. + 1123 S1 = 0 for i in range(

Posted in Uncategorized