curriculum/challenges/english/blocks/daily-coding-challenges-python/696655d24b614176d4c9b78b.md
Given a string representing the width and height of an image, and a number to scale the image, return the scaled width and height.
"WxH". For example, "800x600".Return the scaled dimensions in the same "WxH" format.
scale_image("800x600", 2) should return "1600x1200".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(scale_image("800x600", 2), "1600x1200")`)
}})
scale_image("100x100", 10) should return "1000x1000".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(scale_image("100x100", 10), "1000x1000")`)
}})
scale_image("1024x768", 0.5) should return "512x384".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(scale_image("1024x768", 0.5), "512x384")`)
}})
scale_image("300x200", 1.5) should return "450x300".
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(scale_image("300x200", 1.5), "450x300")`)
}})
def scale_image(size, scale):
return size
def scale_image(size, scale):
width, height = map(int, size.split("x"))
new_width = round(width * scale)
new_height = round(height * scale)
return f"{new_width}x{new_height}"