Рубрики

create

Can you explain the method to create violet?


How to make functions appear purple

So from just learning how to make functions, I thought of if I could turn the function purple, just like a normal print() or str() function. And with that in mind, it may seem pretty obvious that I am still a beginner when it comes to coding. From what I know, it may have something to do with sys.stdin.write , but I don’t know. This will help me to make different languages for others who don’t speak or write English.

Follow
1,844 5 5 gold badges 23 23 silver badges 34 34 bronze badges
asked Feb 16, 2019 at 7:10
nikola markoski nikola markoski
23 5 5 bronze badges
Does this answer work for you?
Feb 17, 2019 at 3:34
Please take a look at updated answer
Feb 19, 2019 at 7:48

2 Answers 2

Sorted by: Reset to default

In Options => Configure IDLE => Settings => Highlights there is a highlight setting for builtin names (default purple), including a few non-functions like Ellipsis . There is another setting for the names in def (function) and class statements (default blue). You can make def (and class) names be purple also.

This will not make function names purple when used because the colorizer does not know what the name will be bound to when the code is run.

Follow
answered Feb 17, 2019 at 7:27
Terry Jan Reedy Terry Jan Reedy
18.5k 3 3 gold badges 41 41 silver badges 53 53 bronze badges
So you’re saying that it is impossible?
Feb 19, 2019 at 2:03

It is effectively impossible for a user who is not prepared to patch IDLE. I am thinking about whether it would be possible to enhance the colorizer to recognize and color function and class names defined earlier in the file.

Feb 19, 2019 at 23:10

Colors for Python

You can install Atom from: https://atom.io

Follow
answered Feb 16, 2019 at 7:27
CodeRaptor CodeRaptor
351 1 1 silver badge 4 4 bronze badges

No, because that is to make words that print to the shell appear a certain colour. My question was a bit vague, but I wanted to have help to find out how to make my own functions appear purple like the functions that idle has. E.g print(“..”) the print function appears purple. However my own functions appear black. Also you don’t need colorama, you can use: import sys try: color = sys.stdout.shell except AttributeError: raise RuntimeError(“Use IDLE”)) and the colors are: ERROR, hit, console, BUILTIN, SYNC, STRING, COMMENT,stdout,stderr,DEFINITION,KEYWORD. Case Sensitive.

Feb 19, 2019 at 1:59

Still no, Because that is changing all the colours of the window. I can do that really easily via options–>configure idle. Still not the right thing, also Terry Jan Reedy said that to do what I want I would need to repatch IDLE. Which I don’t know how to do nor do I want to do for that small aesthetic.


Deep Purple Magic

In this activity, students see colours change in a solution, and learn how chemistry can explain this magical result.

This trick works because iodine is brown when dissolved in water and purple when dissolved in oil.

Pure iodine is violet, but when it’s dissolved in water, it accepts an electron from the oxygen atom, affecting how it absorbs light. When you shake the fluids, the iodine leaves the water and dissolves in the oil, and returns to its purple colour!

The reason the iodine molecules leave water to dissolve in oil is due to how polarity affects solubility. Water is polar; it has an uneven distribution of electrons. Oil is non-polar; electrons in molecules of this substance are distributed evenly. Iodine is also a non-polar molecule therefore it is more soluble in oil; “like dissolves like”.

Objectives

  • Explain the importance of observation when doing science.
  • Per Demo or Student:
    small, clear jar
    water
    oil (mineral or baby oil)
    tincture of iodine
    *All chemicals and solutions are readily available from pharmacies or science supply stores.

Key Questions

  • What colour changes did you notice?
  • What part of the mixture is causing the colour change?
  • Why does the iodine change colour?
  • Does the iodine dissolve more readily in the oil or the water?
  • Why don’t the oil and water mix?

Hint: perform the “magic trick” before you offer an explanation.

  1. Fill the jar about ½ full of water and add iodine until it is about the colour of tea.
  2. Hold it up and slowly add an equal amount of oil so that the students can see the clear oil on top of the amber-coloured water.
  3. Tighten the cap and shake for about 30 seconds. The two layers will need a few moments to form. The bottom layer will be much lighter and the top will be a beautiful purple colour.

Vocabulary:

  • Solution: A mixture of two or more substances, usually in liquid form.
  • Polar molecule: a molecule that has an uneven distribution of molecules from one end to the other.
Colin Wynn
the authorColin Wynn

Leave a Reply