tuomasvaltanen

Untitled

Nov 2nd, 2022 (edited)
965
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.43 KB | None | 0 0
  1. # modules today! 2.11.2022
  2. print("Welcome!")
  3.  
  4. # NEW FILE
  5.  
  6. from colorama import Fore, Back, Style
  7. print(Fore.LIGHTGREEN_EX + 'Different text color!')
  8. print(Back.LIGHTWHITE_EX + 'New background color too!')
  9.  
  10. # reset all styles and colors to normal
  11. print(Style.RESET_ALL)
  12. print('..okay, back to normal.')
  13.  
  14. # NEW FILE
  15.  
  16. from colorama import Fore, Back, Style
  17. print(Fore.RED + 'Different text color!')
  18. print("STILL RED COLOR, YAY!")
  19.  
  20. print(Back.LIGHTBLACK_EX + "Changed the background! BUT STILL RED TEXT!")
  21.  
  22. # reset all styles and colors to normal
  23. print(Style.RESET_ALL)
  24. print('..okay, back to normal.')
  25.  
  26. # NEW FILE
  27.  
  28. from colorama import Fore, Back, Style
  29.  
  30. # ask integer from user
  31. number = input("Give a number:\n")
  32. number = int(number)
  33.  
  34. # green text if positive number, red text otherwise
  35. if number >= 0:
  36.     print(Back.LIGHTGREEN_EX + Fore.BLACK + "Positive number!")
  37. else:
  38.     print(Back.LIGHTRED_EX + Fore.BLACK + "Negative number...")
  39.  
  40. # reset styles to normal
  41. print(Style.RESET_ALL + "THANK YOU!")
  42.  
  43. # NEW FILE
  44.  
  45. # install Pillow module first, then use PIL in code afterwards
  46.  
  47. from PIL import Image, ImageDraw
  48.  
  49. # create a new image, size is 100 x 30
  50. img = Image.new('RGB', (100, 30), color=(73, 109, 137))
  51.  
  52. # create a drawing object
  53. d = ImageDraw.Draw(img)
  54.  
  55. # use drawing object to draw text in the image
  56. d.text((10, 10), "Hello World", fill=(255, 255, 0))
  57.  
  58. # save image to file
  59. img.save('pil_text.png')
Advertisement
Add Comment
Please, Sign In to add comment