OpenLLM-France/wikimedia huggingface dataset:
# Python Programming/Creating Python programs/Solutions

< Back to Problems
1. Modify the hello.py program to say hello to a historical political leader (or to Ada Lovelace).
This is just a matter of replacing world with a different name, for example:
2. Change the program so that after the greeting, it asks, "How did you get here?".
This can be accomplished by adding a second print statement:
3. Re-write the original program to use two print statements: one for "Hello" and one for "world". The program should still only print out on one line.
This can be accomplished by passing the end parameter in the first print statement, and telling it to finish the output with a space (Python 3):
When using Python 2.6 and up, you can use the ',' operator to prevent print from inserting a newline at the end.The ',' instead inserts a space at the end of the string to be printed. When using print as a function, the comma is placed outside the parentheses (Python 2.7.5).
# Python Programming/Cython

Cython (not to be confused with CPython) is a compiler of Python-like source code to the C language, from which it is compiled by a C compiler to binary executable. The objective is a significant speedup compared to interpreting the Python code in CPython, the standard interpreter. Cython is usually used to create extension modules for Python. The source code language compilable by Cython is a near superset of Python.
You can install Cython using pip install Cython. However, in order for Cython to work, you will need a working C compiler. On Linux, you usually have one; on Windows, you can install and use Microsoft Visual C++ compiler or MinGW.
Beyond the normal Python, Cython-compilable Python source can contain C-like declarations of variable types, leading to speedups of the compiled code.
Cython-compilable Python source code files conventionally use extension pyx.
The compiled extension module still needs CPython (the normal Python interpreter) to run, and can call other Python modules, including pure Python modules. This is because, where required, Cython compiles to C code that uses the CPython API to achieve general Python-like behavior.

## External links

* Official website, cython.org
* Basic Tutorial, docs.cython.org
* Cython, pypi.org
* cython, github.com
* Cython, en.wikipedia.org
* Python Interpreters Benchmarks, pybenchmarks.org
# Python Programming/Dbus

| Previous: PyQt4 | Index | Next: pyFormex |
In Linux, Dbus is a way for processes to communicate with each other. For example, programs like Pidgin instant messenger allow other programs to find out or change the user's status (Available, Away, etc). Another example is the network-manager service that publishes which internet connection is active. Programs that sometimes connect to the internet can then pick the best time to download updates to the system.

## Buses

Messages are sent along buses. Services attach themselves to these buses, and allow clients to pass messages to and from them.
There are two main buses, the system bus and session bus. Services on the system bus affect the whole system, such as providing information about the network or disk drives. Services on the session bus provide access to programs running on the desktop, like Pidgin.

## Objects and interfaces

Services attached to a bus can be contacted using their well-known name. While this could be any string, the format is normally that of a reverse domain name: an example for a spreadsheet program called "CalcProgram" from "My Corp Inc." could be "com.mycorp.CalcProgram".
Services publish objects using slash-separated paths (this is similar to webpages). Someone on dbus can request an object if they know this path.
The object passed back is not a full object: it just refers to the service's copy of the object. It is called a proxy object.
Before the proxy object can be used, we need to specify what type of object it is. We do this by creating an interface object.
Whatever methods are set up for this type of object can be called:
| Name | Example | Description |
| service well known name | com.mycorp.CalcProgram | Identifies the application |
| path of an object | /spreadsheet1/cells/a2 | Identifies an object published by a service |
| interface | com.mycorp.CalcProgram.SpreadsheetCell | Identifies what type of object we expect |

## dbus-python examples

These examples have been tested with dbus-python 0.83.0. Older library versions may not have the same interface.
Calling an interface's methods / Listing HAL Devices:
Introspecting an object:
Avahi:

## pydbus examples

These examples have been tested with pydbus 0.2 and 0.3.
Calling an interface's methods / Listing systemd units:
Introspecting an object:
Avahi:

## References

* dbus-python tutorial, dbus.freedesktop.org, Simon McVittie, 2006-06-14
* pydbus README.rst, github.com
* DbusExamples, wiki.python.org
* D-Bus Howto, developer.pidgin.im
* Rough notes: Python and D-Bus, archived version, A.M. Kuchling, 2007, originally at www.amk.ca
| Previous: PyQt4 | Index | Next: pyFormex |
# Python Programming/Date and time

Examples:
* time.sleep(5)
** Sleep for five seconds. Keywords: pause, wait.
* current_time = time.localtime
** Gets the current date and time, as object of time.struct_time type.
* print time.strftime("%Y-%m-%d", time.localtime)
** Outputs the current date in the ISO format, e.g. 2016-03-20.
* print time.strftime("%Y-%m-%d %H:%M:%S", time.localtime)
** Outputs the current date and time, e.g. 2020-04-09 13:37:28.
* baseClock = time.clock; time.sleep(5); print time.clock - baseClock
** Outputs the time elapsed in seconds, as a floating-point number. Is slightly inaccurate.
* print (datetime.date(2016, 3, 20) - datetime.date(2016, 2, 20)).days
** Outputs number of days elapsed between two dates.
** The type of the difference is datetime.timedelta.

## External links

* 15.3. time — Time access and conversions, python.org
* 8.1. datetime — Basic date and time types, python.org
# Structural Biochemistry/Proteins/Purification/High pressure Liquid chromatography

High Pressure Liquid Chromatography (HPLC for short or also called High Performance Liquid Chromatography) is a precise and hi-spec form of column chromatography that can separate and identify components in an unknown (or known) compound mixture.
Like all forms of chromatography, HPLC consists of a stationary phase and a mobile phase. The stationary phase is some solid material packed into the column, while the mobile phase is a liquid solvent that carries the analyzed compound through the column.
Chromatography operates on the principle of polarity where the compound interacts with the solid stationary phase based on their differences in polarity. In general, if the stationary phase is very polar, a non-polar component of the compound would exit the column faster than a polar component would.
# Structural Biochemistry/Proteins/Purification/Hydrophobic Interaction Chromatography
## General Information

Hydrophobic Interaction Chromatography (HIC) (or Hydrophobic Chromatography) is a method of separation by using salt gradients (i.e. ammonium sulfate) to generate hydrophobic interactionsbetween protein and the ligands on the solid phase support resin. The purpose of this type of chromatography is to utilize the hydrophobic properties of specific proteins rather than their charges, which is used in ion-exchange chromatography. Therefore, the more hydrophobic a protein is, stronger it will cling to the column and elution proceeds with the least hydrophobic proteins emerging first from the column. The salt gradient is important because it increases hydrophobic interaction and stabilizes proteins. During elution, other factors besides hydrophobicity still affect how proteins separate, such as ionic interactions, pH, temperature, salt concentration, solvent amount, buffer conditions, etc. These attributes also point to the similarities between HIC and reverse phase chromatography and affinity chromatography. It is important to note that HIC is advantageous because it can be prepared for specific proteins and applied to different facets of protein purification. Conditions may be altered in minor ways to apply the test to many other situations for purification and study purposes, especially in cell membrane studies.

## Resources

* Wikibook:Proteomics - Hydrophobic Interaction Chromatography

## References

* ↑ Tosoh Bioscience. "FAQ's HPLC Columns - HIC". Tosoh Bioscience LLC. Retrieved 2009-10-17.
* ↑ Khalsa, Guruatma. "Chromatography". Arizona State University. Retrieved 2009-10-17.
* ↑ Er-El, Zvi; Shaltiel, Shmuel. "Hydrophobic Chromatography: Use for Purification of Glycogen Synthetase". Proceedings of the National Academy of Sciences of the United States of America. Retrieved 2009-10-17.{{cite web}}: CS1 maint: multiple names: authors list (link)
* Builder, Stuart E. "Hydrophobic Interaction Chromatography: Principles and Methods" (PDF). Amersham Pharmacia Biotech. Retrieved 2009-10-17.
# Structural Biochemistry/Evolution in the Laboratory

In order for evolution to occur, three different processes are required and must be met:
    1. Generation of a diverse population
    2. Selection of members based on criterion of fitness
    3. Reproduction to enrich the population in more-fit members
Nucleic acids are such molecules that are capable of undergoing all three processes. Combinatorial chemistry is the concept of rapidly producing an abundant amount of a specific molecule of interest. Because of this process, diverse populations of nucleic acid molecules can be synthesized. A common example of this process involves attempting to create an RNA molecule that specifically binds ATP and other nucleotides. First, a randomized pool of RNA sequences, called apimers, are placed into an ATP affinity column. Some RNA molecules are then found bounded to ATP. These molecules are released from the affinity column by adding excess ATP. This collection of molecules are allowed to replicate into DNA by using the enzyme reverse transcriptase. Once transcribed into DNA, the molecules undergo PCR, and ultimately transcribe back into RNA.

## References

* ↑ http://www.ncbi.nlm.nih.gov/books/NBK22506/#A963
# Structural Biochemistry/Final Review

Three Sections of Ten Questions Each:
Midterm I Midterm II Midterm III
These are just some basic review questions, please feel free to add more or to correct mistakes.
# Structural Biochemistry/Exergonic reaction
## General information

An exergonic reaction refers to a reaction where energy is released. Because the reactants lose energy (G decreases), Gibbs free energy (ΔG) is negative under constant temperature and pressure. These reactions usually do not require energy to proceed, and therefore occur spontaneously. In a chemical reaction, breaking and forming bonds between atoms is a form of energy. Since chemical reactions mainly consist of forming and/or breaking chemical bonds, exergonic reactions release energy by breaking less stable chemical bonds and forming more stable bonds. The example of exergonic reactions occur in our body is cellular respiration: C6H12O6 (glucose) + 6 O2 -> 6 CO2 + 6 H2O this reaction release energy which is used for cell activities.
However, some exergonic reactions do not occur spontaneously and require a small input of energy to start the reaction. This input of energy is called activation energy. Once the activation energy requirement is fulfilled by an outside source, the reaction proceeds to break bonds and form new bonds and energy is released as the reaction takes place. This results in a net gain in energy in the surrounding system, and a net loss in energy from the reaction system; hence, the change in Gibbs free energy (ΔG)] is negative (ΔG < 0). A negative ΔG denotes that the reaction is spontaneous and thermodynamically favorable.
Here is an endergonic reactions of ATP give energy. First Breaking down the ATP formed ADP and Pi is an exergonic reaction, where Delta G is less than 0. However, by combining the reaction glucose+Pi ---> glucose 6-phosphate, a thermodynamically unfavorable reaction. The cell can drive an endergonic reaction.

## Conclusion

Exergonic reaction is
* Free energy of final state < free energy of initial state
* Free energy is free during the reaction
* The energy can be used to do biological work
* Able to work in spontaneous reaction
* doesn’t have to occur in great rate which is where the enzyme comes in
* -ΔG (negative number)

## Reference

http://academic.brooklyn.cuny.edu/biology/bio4fv/page/exergon.htm
# Structural Biochemistry/Eye Drop
## Definition

Eye drop is a tropical drug administration route in which a medicated solution of saline-containing liquid is administered to the surface of the eye. Though most of the eye drop usually is lost through patient reaction or resides on the surface of the eye, some of the drug enters the bloodstream through the mucous membranes that line the cornea as well as through the conjunctival mucosa and parts of the tear drainage system. A major advantage of eye drop administration is the ease of regular application of high concentrations of medication as well as its lack of need to go through intestinal digestion. Drugs that are administered through the usage of an eye drop can either be in a fully aqueous solution or in suspension (cloudy).
Eye Drop is a drug that is given to patients after eye surgery, or when having severe dry eyes. Eye drops can help with clearing eyes to make it better for sight.

## Types of Eye Drops

1) Rinse eye drops
Rinse eye drops are solutions that help lubricate or replace the tears of the eyes. Rinse eye drops do not necessarily contain any medication. This is the most common form of eye drop administration.
2) Antibiotic and steroid eye drops
Antibiotic and steroid eye drops are predominantly used for treating eye infections. They also can be used to prevent infections from occurring after eye surgeries.
3) Glaucoma eye drops
Glaucoma eye drops assist in the draining of fluid from eyes, which in turn lowers eye pressure. Glaucoma eye drops can vary vastly and are sometimes combined with many other medications that vary on a patient’s need.
4) Antihistamine eye drops
Antihistamine eye drops contain antihistamines, which inhibit a body’s response to allergens. They work by inhibiting the release of histamines into the body. They do not necessarily target the allergens, but allow the patient to cope better with its presence. Antihistamine eye drops are used to lessen the histamine response in the eye.
5) Steroid and antibiotic eye drops
These eye drops are used to treat eye infections. It must be used for the full time prescribed to avoid relapse of the infection. The medication may sting your eyes when first used.
6) Glaucoma eye drops
These eye drops decrease eye pressure by helping the eye's fluid to drain better. They are classified by their active ingredient.

## Side Effects

As many other drugs, eye drops are considered to have some side effects: sore throat, fever, rash, itching, dizziness, swelling. One of the most common side effects is eye redness after using the eye drop. This will lead to pain in eyes or problem with visions that one should be cautious. But in fact, eye drops are less risky than tablet medicines and sometimes, these risks can be prevented from pressing the inner corner of the eye after using. If you do not use them the correct way then you can infect not only one eye, but both eyes.

## Reference

"Generic Name: Steroid and Antibiotic Eye Drops"
"Glaucoma Medications and Their Side Effects"
http://www.patient.co.uk/doctor/Prescribing-for-and-Administration-of-Drugs-to-the-Eye.htm#ref-1
http://development.aao.org/eyecare/treatment/eyedrops.cfm
# QBasic/Files/2

9.1.2 THE DIFFERENT TYPES OF FILES
Sequential files are the simplest. None too surprisingly, these save records in sequence - like lines in a book. The information in Sequential files is stored as ASCII text, so everything you can see on the screen exists in the computer's memory, and these files can be processed by text editors as well as by Qbasic.
# QBasic/Sound

QBasic has three ways of making sounds.
* BEEP command
* SOUND command
* PLAY command

## BEEP

Earlier used as PRINT CHR$(07) the now available BEEP command makes a beep noise. It is commonly used to attract attention, when some important message is being displayed.
The two commands , as can be seen by running this program on a computer, are exactly the same.

## SOUND

The SOUND command produces sound of a specific frequency for a specific duration from the PC Speaker. Only one sound can be played at a time. If multiple SOUND statements are issued sequentially, every statement after the first will not execute until after the previous one finishes.

### Syntax

* f - Frequency in Hertz, ranges from 37 to 32767
* d - Duration in ticks, ranges from 0 to 65535, there are 18.2 ticks per second

### Example

Plays a 100 hertz wave for 18.2 ticks, about 1 seconds.
The lowest frequency allowed by QBasic is 37 Hz, which is roughly a D in the 2nd octave.
The highest frequency is 32 767 Hz, but this tone can not be heard, because the normal human hearing range ends at 20 000 Hz.
A secondary function of the SOUND command is to use it to control time in a program.
This program will print the numbers 1 to 10, with a 1 second delay between each number,and play a sound of 3200hz having interval of 1 second.(edited by FalcoN)

## PLAY

The PLAY command is for playing musical notes,octave. It can only play one note at a time.
More than that the play command can play a complex stored "song" This is accomplished through the use of a song string. For string command detail, see QBasic/Appendix#PLAY.

## Simple Musical Keyboard In Qbasic

This code uses a select case command to check values of note$ . Ucase$ is used to maintain that there be no difference if Caps Lock is applied. The play command is used to play different notes. The other features of play have not been used here.
# QBasic/Images
## WARNING

NONE of these functions work in IDEs other than QB64.

## Simple image

So you were most probably expecting miles of code. And there you have it, all you need to display an image in QB64!
So, what does this astoundingly simple piece of code even do?
A step-by-step explanation:
* We have DIMed our variable Image as a long value. This is because the image handle returned by the _loadimage function is a long value.
* x and y are our variables. They hold the values we need to put as the resolution. Thus ,for a 8n00 x 900 image, x = 800 ,y = 900.
* The image variable Image is next being put the handle values of the image "TEST.jpg". A healthy warning: Keep the image in the folder of the QB64 IDE. Or else, the function won't work!
* Next, we have resized the screen to fit the image. The newimage function requires three parameters, the resolution parameters and the color mode parameters. Here we have used 32-bit color modes, you can also use 256-bit pallete color modes.
* Lastly, we put the image using _putimage, which takes the Image variable (our image handle) as its parameter.

## Secondary use of _newimage for setting screen details

Well, you must be thinking, all these commands must be used in this exact same order. Nah, that isn't the case. You can use _newimage solo, to set the screen details, like shown below:
This code sets the screen to a massive 1000 x 1000 resolution, with 256-bit palette color modes!
# Robotics/Computer Control/Control Architectures

Robots need some form of artificial intelligence in order to be able to navigate around a room or to solve a problem. Such AI can range from simple, as in following particular rules when a specific input is received, through more complicated, as in fuzzy logic rules or simple neural nets, to complicated, as in state of the art machine learning methods.
How complicated you can make your AI depends on a few factors:
* Processing power: How fast is your microprocessor, is it 8-, 16-, or 32-Bit, How many microprocessors do you use?
* Available memory: Both temporary and "permanent" memory. Limited amounts of memory restrict how much data can be held at a time, e.g. a map of the surroundings, sensor history, movement history. Systems with much permanent storage and little ram are slower than systems with large amounts of ram.
* Your knowledge: AI is a very broad subject. Parts of it are very math intensive and can be tricky to understand.
# Robotics/Computer Control/Control Architectures/Hybrid Systems

Hybrid Systems, as evident from name, are a combination of different architectures. For example, a hybrid system may make use of a Subsumption Architecture ( w:Subsumption architecture ) for certain dynamic requirements and a Sense-Plan-Act cycle for some other requirements in a static environment.
# Robotics/Components/Actuation Devices/Shape Memory Alloys

Here is a good introduction about what Shape Memory Alloys (SMA) are.
The main use of SMA in robotics is to imitate human muscles. One of the better known SMAs is Nitinol wire. It contracts about 5 to 7% of its length and consumes a lot of power.
One of the most popular nitinol driven robots is Stiquito.
# Robotics/Computer Control/Control Architectures/Brooks' Subsumption Architecture

Behavior Based Control (BBC): Acting and thinking in layers, with complex logic divided into multiple simpler logic layers.
# Robotics/Computer Control/Control Architectures/Sense-Plan-Act

As obvious from the term, this architecture works through a cycle of Sense, Plan and Act processes.
* By sensing, it means getting the required information from the available sensors and converting it to some usable form.
* Planning refers to the use of available information from sensing phase to determine the control parameters and sequences required for various components in order to make the robot proceed towards final goal.
* Finally, act phase is simply the implementation of the processes and sequences underlined by the planning phase.
This kind of approach is useful if the sensing process is slow and the environment is quite static. For example, on a low speed processor, image processing may require lots of time to process each frame. Hence, it might not be feasible to process every frame and react to the gathered information in real-time. If we use this technique, the information will be processed at a very low frequency, providing more time for other real-time processes to run while still doing the work of planning and acting towards the goal.
# Robotics/Computer Control/Control Architectures/Reactive Systems

These are the simplest and one of the earliest form of control systems for robotics. Some Toys are a common example of these systems. They have a very fast response to the sensed information. However, the drawback of reactive systems is that they have to be very simple. The reactions should be simple and quick enough for the system to work in real-time. These systems have negligible amount of intelligence, but a simple and well-defined behavior. This forms the basis of a Behavior controlled architecture or the Subsumption Architecture ( w:Subsumption architecture ). However, it's mentioned separately from the Subsumption Architecture as it can be used independently in its simplest form to make robots with low intelligence, but high real-time requirements.