Create a function that takes a string and returns that
string with the first half lowercased and the last half uppercased.

eg: foobar == fooBAR

If it is an odd number then 'round' it up to find which letters to uppercase. See example below.

    sillycase("brian")  
    //         --^-- midpoint  
    //         bri    first half (lower-cased)  
    //            AN second half (upper-cased)

Source: codewars | Difficulty: EASY
Tags: String algorithms

Fundamentals

Starter code: def sillycase(silly):
	

Solutions:
def sillycase(silly):
	half = (len(silly) + 1) // 2
	return silly[:half].lower() + silly[half:].upper()


def sillycase(s):
	l = len(s)
	return s[:l // 2 + l % 2].lower() + s[l // 2 + l % 2:].upper()


from math import ceil

def sillycase(silly):
	return silly[:ceil(len(silly) / 2)].lower() + silly[ceil(len(silly) / 2):].upper()


import math

def sillycase(silly):
	t = int(math.ceil(len(silly) / 2.0))
	return silly[:t].lower() + silly[t:].upper()


import math

def sillycase(s):
	return s[:int(math.ceil(len(s) / 2.0))].lower() + s[int(math.ceil(len(s) / 2.0)):].upper()


import math

def sillycase(silly):
	first = silly[:math.ceil(len(silly) / 2)].lower()
	last = silly[math.ceil(len(silly) / 2):].upper()
	return first + last


def sillycase(silly):
	n = len(silly) >> 1
	if ~len(silly) & 1:
		return silly[:n].lower() + silly[n:].upper()
	return silly[:n + 1].lower() + silly[n + 1:].upper()


import math

def sillycase(silly):
	if len(silly) % 2 == 0:
		even_half = len(silly) // 2
		return silly[:even_half].lower() + silly[even_half:].upper()
	else:
		odd_half = math.ceil(len(silly) / 2)
		return silly[:odd_half].lower() + silly[odd_half:].upper()


def sillycase(silly):
	output = ''
	for c in range(len(silly)):
		if c < len(silly) / 2:
			output += str.lower(silly[c])
		else:
			output += str.upper(silly[c])
	return output