python - Invalid Syntax ; probably simple to fix -


this part of code doesn't work. says "there's error in code: invalid syntax." edit: part of code broken: in range(0, len(marks)):

def histogram(data):   def getfrequency(marks):     freqlist = []     in range(0,101):         freqlist.append(0)  in range(0, 101):     starslist = []     in range(0, data[i]):         starslist.append("*")      pad     if data[i] < 10:         pad = " "     elif data[i] < 100:         stars = "" .join(starslist)     print("%d | %s %d" %(i, starslist)       in range(0, len(marks)):       mark = marks[i]     freqlist[mark] += 1  return freqlist   freq = getfrequency(marks) mode = maximum(freq)  #print (freq) 

this rest of code (which above part error). may or may not riddled errors. put here in case relevant.

import random

def bubblesort(data): count = 0 in range(0,len(data) - 1): j in range(0, len(data) - 1): count += 1 if data[j] > data[j+1]: #swap temp = data[j] data[j] = data[j + 1] data[j + 1] = temp print(count) return data

data = [5,4,3,2,1] data = bubblesort(data) print(data)

def getdata():

data = []  in range(0, 100):     data.append(random.randint(0,100)) return data 

def mean(data):

total = 0  in range (0, len(data)):     #add data[i]     total = total + data[i]  return total/ len(data) 

def maximum(data):

maximum = data[0]  in range(0, len(data)):     if maximum < data[i]:         maximum = data[i]  return maximum 

def minimum(data):

minimum = data[0]  in range(0, len(data)):     if minimum > data[i]:         minimum = data[i]  return minimum 

def mode(data):

marks = getdata()

you're missing right parenthesis here:

print("%d | %s %d" %(i, starslist) 

Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

ios - Possible to get UIButton sizeThatFits to work? -