Sunday, June 13, 2021

Python (4) Exception Handling [20210613]



Errors and Exceptions

8.1. Syntax Errors

Syntax errors, also known as parsing errors, are perhaps the most common kind of complaint you get while you are still learning Python:
>>> >>> while True print('Hello world') File "<stdin>", line 1 while True print('Hello world') ^ SyntaxError: invalid syntax
The parser repeats the offending line and displays a little ‘arrow’ pointing at the earliest point in the line where the error was detected. The error is caused by (or at least detected at) the token preceding the arrow: in the example, the error is detected at the function print(), since a colon (':') is missing before it. File name and line number are printed so you know where to look in case the input came from a script. An example of name error and package resolution
(base) C:\Users\Ashish Jain\OneDrive\Desktop>python Python 3.7.1 (default, Dec 10 2018, 22:54:23) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32 Type "help", "copyright", "credits" or "license" for more information. >>> re Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 're' is not defined >>> import re >>> re <module 're' from 'E:\\programfiles\\Anaconda3\\lib\\re.py'> >>> exit()

8.2. Exceptions

Even if a statement or expression is syntactically correct, it may cause an error when an attempt is made to execute it. Errors detected during execution are called exceptions and are not unconditionally fatal: you will soon learn how to handle them in Python programs. Most exceptions are not handled by programs, however, and result in error messages as shown here: >>> >>> 10 * (1/0) Traceback (most recent call last): File "<stdin>", line 1, in <module> ZeroDivisionError: division by zero >>> 4 + spam*3 Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'spam' is not defined >>> '2' + 2 Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: Can't convert 'int' object to str implicitly The last line of the error message indicates what happened. Exceptions come in different types, and the type is printed as part of the message: the types in the example are ZeroDivisionError, NameError and TypeError. The string printed as the exception type is the name of the built-in exception that occurred. This is true for all built-in exceptions, but need not be true for user-defined exceptions (although it is a useful convention). Standard exception names are built-in identifiers (not reserved keywords). The rest of the line provides detail based on the type of exception and what caused it. The preceding part of the error message shows the context where the exception occurred, in the form of a stack traceback. In general it contains a stack traceback listing source lines; however, it will not display lines read from standard input. Built-in Exceptions lists the built-in exceptions and their meanings.

8.3. Handling Exceptions

It is possible to write programs that handle selected exceptions. Look at the following example, which asks the user for input until a valid integer has been entered, but allows the user to interrupt the program (using Control-C or whatever the operating system supports); note that a user-generated interruption is signalled by raising the KeyboardInterrupt exception.
>>> >>> while True: ... try: ... x = int(input("Please enter a number: ")) ... break ... except ValueError: ... print("Oops! That was no valid number. Try again...") ...
The try statement works as follows. 1. First, the try clause (the statement(s) between the try and except keywords) is executed. 2. If no exception occurs, the except clause is skipped and execution of the try statement is finished. 3. If an exception occurs during execution of the try clause, the rest of the clause is skipped. Then if its type matches the exception named after the except keyword, the except clause is executed, and then execution continues after the try statement. 4. If an exception occurs which does not match the exception named in the except clause, it is passed on to outer try statements; if no handler is found, it is an unhandled exception and execution stops with a message as shown above. ~ ~ ~ A try statement may have more than one except clause, to specify handlers for different exceptions. At most one handler will be executed. Handlers only handle exceptions that occur in the corresponding try clause, not in other handlers of the same try statement. An except clause may name multiple exceptions as a parenthesized tuple, for example: ... except (RuntimeError, TypeError, NameError): ... pass A class in an except clause is compatible with an exception if it is the same class or a base class thereof (but not the other way around — an except clause listing a derived class is not compatible with a base class). For example, the following code will print B, C, D in that order:
class B(Exception): pass class C(B): pass class D(C): pass for cls in [B, C, D]: try: raise cls() except D: print("D") except C: print("C") except B: print("B")
OUT: (base) C:\Users\Ashish Jain\OneDrive\Desktop>python script2.py B C D ~ ~ ~
class B(Exception): pass class C(B): pass class D(C): pass for cls in [B, C, D]: try: raise cls() except B: print("B") except C: print("C") except D: print("D")
OUT: (base) C:\Users\Ashish Jain\OneDrive\Desktop>python script3.py B B B ~ ~ ~ Another example "Division By Zero"
#Handling run-time error: division by zero def this_fails(): x = 1/0 try: this_fails() except ZeroDivisionError as err: print('Handling run-time error:', err)
Modified version:
def division(a, b): print("a:", a) print("b:", b) if b == 0: raise Exception return a/b try: print("Success:", division(5, 5)) division(5, 0) except ZeroDivisionError as err: print('Handling run-time error:', err)
OUT: (base) C:\Users\Ashish Jain\OneDrive\Desktop>python script5.py a: 5 b: 5 Success: 1.0 a: 5 b: 0 Traceback (most recent call last): File "script5.py", line 10, in <module> division(5, 0) File "script5.py", line 5, in division raise Exception Exception

# Defining Clean-up Actions

If a finally clause is present, the finally clause will execute as the last task before the try statement completes. The finally clause runs whether or not the try statement produces an exception. The following points discuss more complex cases when an exception occurs: 1. If an exception occurs during execution of the try clause, the exception may be handled by an except clause. If the exception is not handled by an except clause, the exception is re-raised after the finally clause has been executed. 2. An exception could occur during execution of an except or else clause. Again, the exception is re-raised after the finally clause has been executed. 3. If the finally clause executes a break, continue or return statement, exceptions are not re-raised. 4. If the try statement reaches a break, continue or return statement, the finally clause will execute just prior to the break, continue or return statement’s execution. 5. If a finally clause includes a return statement, the returned value will be the one from the finally clause’s return statement, not the value from the try clause’s return statement. For example:
>>> >>> def bool_return(): ... try: ... return True ... finally: ... return False ... >>> bool_return() False

# Yet Another Division by Zero Example

def division(a, b): print("a:", a) print("b:", b) if b == 0: raise ZeroDivisionError return a/b try: print("Success:", division(5, 5)) division(5, 0) except ZeroDivisionError as err: print('Handling run-time error:', err)
Ref: docs.python.org Tags: Technology,Python,Anaconda,

Saturday, June 12, 2021

Pari 10 (Tablet, Psychiatry)



Pari 10 Tablet
Prescription: Required
Manufacturer: Ipca Laboratories Ltd
SALT COMPOSITION: Paroxetine (10mg)
Storage: Store below 30°C

Introduction

Pari 10 Tablet is a type of antidepressant belonging to the selective serotonin reuptake inhibitor (SSRI) group of medicines. It is widely prescribed to treat depression and anxiety-related conditions like obsessive-compulsive disorder, and panic disorder.

Pari 10 Tablet helps many people to recover from depression by improving their mood and relieving anxiety and tension. It can be taken with or without food. The dose and how often you need it will be decided by your doctor so that you get the right amount to control your symptoms.

Your doctor may start you on a lower dose and increase it gradually. Do not change the dose or stop taking it without talking to your doctor, even if you feel well. Doing so may make your condition worse or you may suffer from unpleasant withdrawal symptoms (anxiety, restlessness, palpitations, dizziness, sleep disturbances, etc).

To get the most benefit, take this medicine regularly at the same time each day. Your doctor may advise you to take it in the morning if you have trouble sleeping. It may take a few weeks before you start feeling better. Let your doctor know if you do not see any improvement even after 4 weeks.

Some common side effects of Pari 10 Tablet include nausea, fatigue, dry mouth, loss of appetite, increased sweating, dizziness, nervousness, tremors, insomnia (difficulty in sleeping), and constipation. Sexual side effects like decreased sexual drive, delayed ejaculation, and erectile dysfunction may also be seen. Let your doctor know straight away if you develop any sudden worsening of mood or any thoughts about harming yourself.

Before taking this medicine, you should tell your doctor if you have epilepsy (seizure disorder or fits), diabetes, liver or kidney disease, heart problems, or glaucoma. These may affect your treatment. Pregnant or breastfeeding women should also consult their doctor before taking it. Some other medicines may affect the way it works, especially other antidepressants and medicines called MAO inhibitors. Please tell your doctor about all the medicines you are taking to make sure you are safe.

Uses of Pari Tablet

1. Depression
2. Panic disorder
3. Anxiety disorder

Benefits of Pari Tablet

1. In Depression

Pari 10 Tablet works by increasing the level of a chemical called serotonin in the brain. This improves your mood, relieves anxiety, tension, and helps you sleep better. It has fewer side effects than older antidepressants. It usually takes 4-6 weeks for this medicine to work so you need to keep taking it even if you feel it is not working. Do not stop taking it, even if you feel better unless your doctor advises you to.

2. In Panic disorder

Pari 10 Tablet can help relieve symptoms of many panic disorders including panic attacks. It can help you feel calmer and improve your ability to deal with problems. Do not stop taking it, even when you feel better, unless your doctor advises you to.

3. In Anxiety disorder

Pari 10 Tablet helps relieve symptoms of many anxiety disorders including obsessive-compulsive disorder and generalized anxiety disorder by increasing the level of a chemical called serotonin in your brain. It has fewer side effects than older antidepressants and is normally taken once a day. It helps you feel calm with a better ability to deal with problems. Exercise and a healthy diet can also improve your mood. Keep taking the medicine until your doctor advises you to stop.

Side effects of Pari Tablet

Most side effects do not require any medical attention and disappear as your body adjusts to the medicine. Consult your doctor if they persist or if you’re worried about them.

Common side effects of Pari:

1. Nausea
2. Fatigue
3. Dryness in mouth
4. Loss of appetite
5. Increased sweating
6. Dizziness
7. Nervousness
8. Tremor
9. Insomnia (difficulty in sleeping)
10. Low sexual desire
11. Confusion
12. Constipation
13. Erectile dysfunction
14. Delayed ejaculation
15. Decreased libido

Quick Tips

1. It can take 2-3 weeks for Pari 10 Tablet to start working.
2. Do not stop treatment suddenly as this may cause upset stomach, flu-like withdrawal symptoms, and sleep disturbance.
3. If your doctor asks you to stop Pari 10 Tablet, you should reduce the dose slowly over 4 weeks.
4. Avoid consuming alcohol when taking Pari 10 Tablet, as it may cause excessive drowsiness and calmness.
5. The addiction/dependence potential of Pari 10 Tablet is very less.

Fact Box

Chemical Class: Phenylpiperidine Derivative
Habit Forming: No
Therapeutic Class: NEURO CNS
Action Class: Selective Seretonin Reuptake inhibitors (SSRIs)

MEDICINE INTERACTION

1. Pari 10 Tablet & Linaz 600mg Tablet

2. Pari 10 Tablet & Linwel 600mg Tablet

3. Pari 10 Tablet & Cadlizo 600mg Tablet

4. Pari 10 Tablet & Linezo 600mg Tablet

5. Pari 10 Tablet & Genolid Tablet

6. Pari 10 Tablet & Lenazol 600mg Tablet

7. Pari 10 Tablet & Linzobus Dry Syrup

8. Pari 10 Tablet & Linopik OD Tablet SR

9. Pari 10 Tablet & Linzomax 600mg Tablet

10. Pari 10 Tablet & Linzomax IV 600mg Infusion

Concurrent use of Linezolid and Paroxetine should be avoided.
Tags: Medicine, Science, Technology, Psychology

Corruption (Ann Mumo, 20210613)



Corruption 1) Governance: For our governments to be stable and effective, we must fight corruption. 2) Strong Judicial System: We should ensure that leaders and government agents became answerable to the taxpayer. 3) Education: The public should be educated on the ills of corruption. 4) Right to Information (RTI) Against The Corrupt Citizens: While those who have stolen public funds are made to return it and face the full force of the law. 5) Right to Information (RTI) Against The Tax Havens: Again, people known to have stashed money in foreign banks should be forced to repatriate that money so as to improve cash flow in our economies. This will put our countries on the road to prosperity. 6) Digitization of The Economy: Through digitization of the economy, we can bring in transparency, and corruption would reduce. Tags: Indian Politics,Politics,Banking,Investment,Kenya,Management,Technology,

Friday, June 11, 2021

Doctors and Human Rights Violation (Ann Mumo)



The medical profession has a long tradition of respect for human rights. However a small number of doctors and health professional have betrayed ethical norms and insisted in abuses against detainees and prisoners. AL medical groups in many countries around the world campaign for an end of medical participation in human rights violations. In countries where human rights violations are widely spread, medical personnel can have access to prisoners in circumstances where the prisoner is denied other protective contact such as with legal counsel or with family. For these reasons, doctor's role "I'm safeguarding the health and security of the prisoner" is of considerable importance. Where human rights violations are not systematic or not even a major concern, the doctors can still play a protective role. But in many countries this role of protection is negated by the failure of medical personnel to adhere to basic tenets of medical ethics. It is not possible to determine the number of individual abuses involving doctors nor the number of doctors involved in human rights violations around the world. The definition of what constitutes medical involvements is not clear. The number of doctors consciously and deliberately engaging in torture and other cruel inhuman and degrading treatment or punishment represent a tiny proportion of profession. The number of those who are aware of abuses carried out against prisoners by police, security or prisoners officer is much more substantial. Medical involvement in torture ranges from the inflection of torture by the doctors themselves, through acting as an adviser or medical supervisors of torture to the false certification of health or of death after torture has been afflicted. In many case's, the behaviors of the doctors encompasses more than one of these roles. The role of doctors in torture stem from his medical expertise. The doctors appear to play the role of advisory during torture rather than inflicting torture personally. However, there is a fine line between inflicting torture and assisting others to carry it out, and doctors who are present during torture can easily slip from one role to the other. In some cases, a medical activity such as administering medication by intravenous injection may appear to the prisoner to be threatening or even a form of torture. When doctors administer substances in the absence of therapeutic need and with the intention to cause suffering they become torturous. Moreover, the vulnerability of the prisoners and the sense of betrayed which he or she experiences when confronted by a doctor who is working with torture can itself amplify the suffering. AL have received evidence and numerous testimonies from prisoners. In Morocco, a prisoner alleged in 1986 that a medical person was involved in the torture. Doctors may be present during torture to prevent the death of the prisoner or to ensure that the prisoner leaves no mark. The torture were highly trained in methods of exacting the maximum pain without leaving any significant physical traces. AL has received reports of medical examination being genuine just prior to the appearance in court. It has also documented the use of medical certificates to falsely indicate that the prisoner has been released from custody. In some cases it is not clear whether certificates have been deliberately falsified or are incompetently prepared. Pressure is sometimes applied to medical personnel to withhold or to falsify evidence. The participation of doctors in such punishment has been documented. Powerful antipsychotic drugs have in the past been regularly administered to prisoners. Medical personnel have also failed to protect patients from arbitrary violence inflicted by nurse or guards. There has been a long tradition of medical attendance at executions in Europe. The presence of doctors in the execution chamber could result in their having to participate in the execution process even where the method is not at all.Some doctors have placed the interest of security forces of the prisoners. Over two thousands years after Hippocrates, it is surely that all medical practitioners must observe the dictum "Above all, do no harm". Notes Primum non nocere (Classical Latin: [ˈpriːmũː noːn nɔˈkeːrɛ]) is a Latin phrase that means "first, do no harm". The phrase is sometimes recorded as primum nil nocere. Non-maleficence, which is derived from the maxim, is one of the principal precepts of bioethics that all students in healthcare are taught in school and is a fundamental principle throughout the world. Another way to state it is that, "given an existing problem, it may be better not to do something, or even to do nothing, than to risk causing more harm than good." It reminds healthcare personnel to consider the possible harm that any intervention might do. It is invoked when debating the use of an intervention that carries an obvious risk of harm but a less certain chance of benefit. Non-maleficence is often contrasted with its corollary, beneficence. Tags: Kenya,Indian Politics,Politics,Behavioral Science,Medicine,Psychology,Science,

Quick Setup Tips by GitHub itself



Both together:
Tags: Technology,GitHub,Cloud

Thursday, June 10, 2021

Maximum Dosage of Saridon Pill



Saridon: Key ingredients

1. Paracetamol I.P.: 250 mg 2. Propyphenazone I.P.: 150 mg 3. Caffeine I.P. (anhydrous): 50 mg

Acetaminophen safe dosage basics

Ref: health.harvard.edu Acetaminophen controls pain and fever but does not reduce inflammation, as does aspirin and the other widely consumed nonsteroidal anti-inflammatory drugs (NSAIDs) ibuprofen (Advil, Motrin, generics) and naproxen (Aleve, generics). But unlike NSAIDs, acetaminophen does not irritate the stomach and intestinal lining. That means a person who cannot tolerate NSAIDs can still take acetaminophen. It's an important drug for controlling chronic pain in older adults. How to stay within limits If you ever have concerns about how much acetaminophen you can tolerate based on your age, body size, and health status, talk to your doctor or pharmacist. Here are some general precautions for avoiding an accidental overdose of acetaminophen. 1. Cold and flu remedies count. When you reach for an over-the-counter cough, cold, or flu product, take a look at the label. Does it contain acetaminophen? 2. Know the milligrams in your pills. In acetaminophen products available over the counter, each pill may contain 325, 500, or 650 milligrams of the drug. Be extra cautious when taking 500 or 650 milligram pills. 3. Stick to recommended doses. When taking acetaminophen, don't be tempted to add a little extra to the recommended dose. A small-bodied person should stay on the low end of the recommended dose range (3,000 mg). 4. Easy on the alcohol. Drinking alcohol causes the liver to convert more of the acetaminophen you take into toxic byproducts. Men should not have more than two standard drinks per day when taking acetaminophen (one drink per day for women). 5. Know if your medications interact. Ask your doctor or pharmacist if any of your prescription medications could interact badly with acetaminophen. Acetaminophen: How much can you take safely? 325 mg ## 500 mg ## 650 mg extended release Take how many pills at a time?: 1 or 2 ## 1 or 2 ## 1 or 2 Take how often?: Every 4 to 6 hours ## Every 4 to 6 hours ## Every 8 hours Safest maximum daily dose for most adults: 8 pills ## 6 pills ## 4 pills Never take more than this in a 24-hour period: 12 pills (3900 mg) ## 8 pills (4000 mg) ## 6 pills (3900 mg) Saridon has 250mg of Paracetamol: maximum daily dosage to sum upto 4000mg => 16 pills ~ ~ ~

Propyphenazone: Maximum Dosage

Ref: medindia.net In India: Dart (300mg/150mg/50mg) • The recommended dose of the drug is 75 to 150 mg tablet orally. • Propyphenazone should be taken up to a maximum of four times a day. Maximum Dosage: 4 pills ~ ~ ~

Caffeine

Ref: mayoclinic.org How much is too much? Up to 400 milligrams (mg) of caffeine a day appears to be safe for most healthy adults. That's roughly the amount of caffeine in four cups of brewed coffee, 10 cans of cola or two "energy shot" drinks. Keep in mind that the actual caffeine content in beverages varies widely, especially among energy drinks. Caffeine in powder or liquid form can provide toxic levels of caffeine, the U.S. Food and Drug Administration has cautioned. Just one teaspoon of powdered caffeine is equivalent to about 28 cups of coffee. Such high levels of caffeine can cause serious health problems and possibly death. You drink more than 4 cups of coffee a day You may want to cut back if you're drinking more than 4 cups of caffeinated coffee a day (or the equivalent) and you have side effects such as: 1. Headache 2. Insomnia 3. Nervousness 4. Irritability 5. Frequent urination or inability to control urination 6. Fast heartbeat 7. Muscle tremors Maximum Dosage of Saridon based on Caffeine content: (400 / 50) mg: 8 pills

Based on the constituent salts: The maximum dosage of Saridon comes out to be 4 pills (based on maximum dosage of Propyphenazone)

References

1. SC exempts painkiller Saridon from the banned list in India, September 2018 2. Tension headache - Wikipedia 3. International Classification of Headache Disorders 4. survival8 Tags: Medicine,Science,

Wednesday, June 9, 2021

Audience Around The World (Jun 2021)



Now [Last 2 Hours]
Day
Week
Month
3 Months
6 Months
12 Months
All Time
Note: We started promotion in Kenya since 25th April 2021. Tags: Data Visualization,Investment,Management,

Sunday, June 6, 2021

The Corona Style (by Joseph Owaga)



1. Surviving in curfew times

• Then at once it went, the president reduced working hours to curb the spread of the dreadful Corona virus.
• The policemen as usual were to ensure the rule is upheld and the safety of the citizens. However, this turned to be a different thing the police know found a means of exploiting the citizens up and down, left, right and center. • The operational hours could not allow the clubs to hold their customers any longer. Many found themselves jobless as the number of clients reduced.

2. THE DOCTOR STYLE

i. Who could ever imagine this... everyone behind a face mask. Everybody resembled a doctor on it’s own. ii. Failure to have the face mask became an offense payable by forced quarantine, after a bond of $5. iii. At first the prices of the face mask threatened many as only the 'few' could manage to buy then however, it became cheap afterwards as it flooded into the market in large numbers. iv. Many people were grefull for the mask for it not only helped to reduce the spread of Covid 19 but also other diseases. v. The worst part now came, most of the mask were not biodegradable and this pilled lots of trash in the environment, both in water and on land.

3. The closure of schools And worship places.

On March 1st of 2020 the president announced of the arrival of the virus into Kenya. And after 2 weeks there was nothing to be done the president called for a closure for the schools to avoid overcrowding and 1m meter social distance that was not possible in such institutions.

INSTITUTING TOTAL LOCKDOWN

• Finally to reduce quick transfer of the virus the counties with highest number of infections had no choice to travel out of their countries. • The flights from outside the country was also terminated as it could possibly leak more viruses from other parts, however, the cargo planes were still allowed to operate.

OTHER WAYS THAT WERE INSTITUTED TO REDUCE THE SPREAD OF THE VIRUS

• Frequent sanitizing of hands • Avoiding handshakes, hugging and kissing friends • Avoiding crowded places • Keep Distance at Events and Gatherings: was seid to be safest to avoid crowded places and gatherings where it may be difficult to stay at least 6 feet away from others who are not from your household. If you are in a crowded space, try to keep 6 feet of space between yourself and others at all times, and as it was suggested by the ministry of health

SOCIAL DISTANCE TIPS THAT WERE SET BY THE MINISTER OF HEALTH

• When going out in public, it is important to stay at least 6 feet away from other people and wear a mask to slow the spread of COVID-19. Consider the following tips for practicing social distancing when you decide to go out. • Know Before You Go: Before going out, know and follow the guidance from local public health authorities where you live. • Prepare for Transportation: Consider social distancing options to travel safely when running errands or commuting to and from work, whether walking, bicycling, wheelchair rolling, or using public transit, rideshares, or taxis. When using public transit, try to keep at least 6 feet from other passengers or transit operators – for example, when you are waiting at a bus station or selecting seats on a bus or train. When using rideshares or taxis, avoid pooled rides where multiple passengers are picked up, and sit in the back seat in larger vehicles so you can remain at least 6 feet away from the driver.
Tags: Kenya,Politics,Behavioral Science,Emotional Intelligence,Psychology,

Scientific Devew in Agriculture (Ann Mumo)



In recent times, there have been marked technological advancements in agriculture. There has been a move towards genetically modified crops, use of chemical fertilizers and intensive use of pesticides. Although this has been hailed by all as the only way to ensure food sustenance in Africa, it has come with it's obvious costs.

To begin with, the use of nitrogenous fertilisers has no doubt led to increased yields in agriculture, raising hopes for farmers whose soils have became exhausted out continued tilling year in, year out. However, intensive use of chemical fertilisers has changed the soil pH. Many farmers lack knowledge on maintaining the correct soil pH. Such a soil loses its productivity. On the same note, there are pollution hazards poses by excess nitrates if washed into rivers.

Secondly, there has been the introduction of new strains of food crops which promise high yields. The produce of the new crop cannot be used as seed in the next season. This means farmers have to dig deeper in their pockets every time of planting.

The extensive use of pesticides has ensured trouble free farming. The common crop pests have been effectively eliminated. This means the farmer can easily estimate the amount of harvest he/she will have at head of the season. This notwithstanding, the level and intensity of this pesticides is often uncontrolled. Sometimes, dangerous level of pesticides residue are left in the produce. This is health hazard. Apart from that, pesticides indiscriminately kills all organisms in the farm, often disturbing the delicate balance of nature.

No one can deny that scientific achievement are here to stay and have improved the quality of life. They, however, should not be adopted if there is any danger to humans and their environment. Agricultural scientist's should tend towards the sustenance of indigenous food crops, enhance organic farming and explore possibilities of biological control of crop pests.

Title: Scientific Devew in Agriculture (Ann Mumo)
Tags: Kenya,Politics,

Strike action is an expensive affair! (Ann Mumo)



My friends, I beg you to listen to me before you go ahead with your plans. Going on strike is expensive. How many of us have paused to think of the consequences? If we on strike tonight, we are bound to damage property. Buildings may be razed down and furnitures broken. What about the injuries we are likely to sustain? Who will pay for the damage? Our parents will have to pay for it all. This is adding to the already heavy burden of paying school fees. Why should we do this to them? Comrades, we have walked together for long, will we accomplish this if we distrust classes? And who will be the ultimate loser anyway? My colleagues let's wake up to this reality. We are here for a reason. Let's explore others options in solving our problems. Title: Strike action is an expensive affair! (Ann Mumo) Tags: Kenya,Politics,Behavioral Science,Emotional Intelligence,Psychology,

Mob justice is not justice at all! (Ann Mumo)



Mob justice is not justice at all! By: Ann Mumo There is no justification for mob Justice I'm a civilized society. More often than not,the victims are suspects of petty crimes such as pickpocketing. Does anyone deserve to die for snatching a purse? Mob Justice amounts to dodging the court process, defeats the rule of natural Justice and perpetuates violence in society. The first assumption of the law is that the suspect is deemed innocent until proven guilty in the court of law. Some people claim that the court process is long and that it often set free otherwise guilty persons for lack of credible evidence. However, Mob justice goes against the rules of natural Justice. The public assumes the roles of the complainants, the prosecutor, the jury and judge. Every person suspected of crimes should be allowed to go through the court process so as to get fair hearing. Mob justice is known to have been claimed innocent victims and should be avoided at all costs. Secondly, killing of crimes suspects derail the efforts by the government to control crimes. When a suspect is killed, he dies with information that could be useful to the police. Although some people say that suspects handed over to police are realised uncharged, it would be unwise to public to take the law in their hands. Suspects should be apprehended so as to help police in their investigationa. This assists in nabbing other criminals linked to the arrested suspect and help in prevention of crime. Thirdly, mob Justice is a display of lawlessness and uncivil behavior in society. Many times, we get treated to the gory details of unsightly scenes on our TV screens. Tags: Kenya,Politics,Behavioral Science,Emotional Intelligence,Psychology,

Saturday, June 5, 2021

Python (3) RegEx in Python [20210606]



We had covered Strings in our previous session, which can be found here:
Python (2) String and related packages [20210523]


In this post, we are covering the Python package "re", which stands for RegEx or Regular Expressions.

First step towards working with "RegEx" is by importing the "re" package. Without importing "re", package Python would not know what you are mean by "re".

(base) C:\Users\Ashish Jain>python
Python 3.7.1 (default, Dec 10 2018, 22:54:23) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> re

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 're' is not defined

>>> import re
>>> re

<module 're' from 'E:\\programfiles\\Anaconda3\\lib\\re.py'>
>>>

RegEx Functions At a High Level

The re module offers a set of functions that allows us to search a string for a match:

findall : Returns a list containing all matches
search  : Returns a Match object if there is a match anywhere in the string
split   : Returns a list where the string has been split at each match
sub     : Replaces one or many matches with a string

A Regular Expression composed using following parts: Metacharacters, Special Sequences, and Sets.

Metacharacters: These are the characters with a special meaning Character: Description: Example [] A set of characters "[a-m]" \ Signals a special sequence (can also be used to escape special characters): "\d" . Any character (except newline character): "he..o" ^ Starts with "^hello" $ Ends with: "world$" * Zero or more occurrences: "aix*" + One or more occurrences: "aix+" ? Zero or one occurences: "r.?" {} Exactly the specified number of occurrences "al{2}" | Either or "falls|stays" () Capture and group Special Sequences: It is a \ followed by one of the characters in the list below, and has a special meaning: Character: Description: Example \A Returns a match if the specified characters are at the beginning of the string "\AThe" \b Returns a match where the specified characters are at the beginning or at the end of a word (the "r" in the beginning is making sure that the string is being treated as a "raw string") r"\bain" r"ain\b" \B Returns a match where the specified characters are present, but NOT at the beginning (or at the end) of a word (the "r" in the beginning is making sure that the string is being treated as a "raw string") r"\Bain" r"ain\B" \d Returns a match where the string contains digits (numbers from 0-9) "\d" \D Returns a match where the string DOES NOT contain digits "\D" \s Returns a match where the string contains a white space character "\s" \S Returns a match where the string DOES NOT contain a white space character "\S" \w Returns a match where the string contains any word characters (characters from a to Z, digits from 0-9, and the underscore _ character) "\w" \W Returns a match where the string DOES NOT contain any word characters "\W" \Z Returns a match if the specified characters are at the end of the string Sets: A set is a set of characters inside a pair of square brackets [] with a special meaning: Set: Description [arn] Returns a match where one of the specified characters (a, r, or n) are present [a-n] Returns a match for any lower case character, alphabetically between a and n [^arn] Returns a match for any character EXCEPT a, r, and n [0123] Returns a match where any of the specified digits (0, 1, 2, or 3) are present [0-9] Returns a match for any digit between 0 and 9 [0-5][0-9] Returns a match for any two-digit numbers from 00 and 59 [a-zA-Z] Returns a match for any character alphabetically between a and z, lower case OR upper case [+] In sets, +, *, ., |, (), $,{} has no special meaning, so [+] means: return a match for any + character in the string The findall() Function The findall() function returns a list containing all matches. The list contains the matches in the order they are found. import re txt = "The rain in Spain" x = re.findall("ai", txt) print(x) ['ai', 'ai'] txt = "The rain in Spain detected by Mr Jain." x = re.findall("ai", txt) print(x) ['ai', 'ai', 'ai'] txt = "The rain in Spain detected by Mr Jain." x = re.findall("r.?", txt) print(x) ".?" means zero or one occurence of any character, so we get the characters 'a' and ' '. ['ra', 'r '] txt = "The rain in Spain detected by Mr Jain." x = re.findall("r\w?", txt) print(x) "\w?" means zero or one occurence of any word character, so we get the characters 'ra' and only 'r'. ['ra', 'r'] If no matches are found, an empty list is returned. import re txt = "The rain in Spain" x = re.findall("Portugal", txt) print(x) The search() Function The search() function searches the string for a match, and returns a Match object if there is a match. If there is more than one match, only the first occurrence of the match will be returned. import re txt = "The rain in Spain" x = re.search("\s", txt) print("The first white-space character is located in position:", x.start()) The first white-space character is located in position: 3 - - - txt = "The rain in Spain" x = re.search("\s", txt) print(x) <re.Match object; span=(3, 4), match=' '> If no matches are found, the value None is returned. import re txt = "The rain in Spain" x = re.search("Portugal", txt) print(x) The split() Function The split() function returns a list where the string has been split at each match: import re txt = "The rain in Spain" x = re.split("\s", txt) print(x) ['The', 'rain', 'in', 'Spain'] You can control the number of occurrences by specifying the maxsplit parameter: Split the string only at the first occurrence: import re txt = "The rain in Spain" x = re.split("\s", txt, maxsplit = 1) print(x) x = re.split("\s", txt, maxsplit = 2) print(x) ['The', 'rain in Spain'] ['The', 'rain', 'in Spain'] The sub() Function The sub() function replaces the matches with the text of your choice: import re txt = "The rain in Spain" x = re.sub("\s", "9", txt) print(x) The9rain9in9Spain You can control the number of replacements by specifying the count parameter: Replace the first 2 occurrences: import re txt = "The rain in Spain" x = re.sub("\s", "9", txt, count = 1) print(x) x = re.sub("\s", "9", txt, count = 2) print(x) The9rain in Spain The9rain9in Spain Match Object A Match Object is an object containing information about the search and the result. Note: If there is no match, the value None will be returned, instead of the Match Object. Do a search that will return a Match Object: import re txt = "The rain in Spain" x = re.search("ai", txt) print(x) #this will print an object Print all the methods or attributes on Match object: print(x.__dir__()) ['__repr__', '__getitem__', 'group', 'start', 'end', 'span', 'groups', 'groupdict', 'expand', '__copy__', '__deepcopy__', '__class_getitem__', 'string', 're', 'pos', 'endpos', 'lastindex', 'lastgroup', 'regs', '__doc__', '__hash__', '__str__', '__getattribute__', '__setattr__', '__delattr__', '__lt__', '__le__', '__eq__', '__ne__', '__gt__', '__ge__', '__init__', '__new__', '__reduce_ex__', '__reduce__', '__subclasshook__', '__init_subclass__', '__format__', '__sizeof__', '__dir__', '__class__'] The Match object has properties and methods used to retrieve information about the search, and the result: .span() returns a tuple containing the start-, and end positions of the match. .string returns the string passed into the function .group() returns the part of the string where there was a match txt = "The rain in Spain" x = re.search(r"\bS\w+", txt) print(x) print("span:", x.span()) print("string:", x.string) print("group:", x.group()) print("start:", x.start()) <re.Match object; span=(12, 17), match='Spain'> span: (12, 17) string: The rain in Spain group: Spain start: 12 txt = "Mr Jain enjoyed the rain in Spain." x = re.search(r"\bS\w+", txt) print(x) print("span:", x.span()) print("string:", x.string) print("group:", x.group()) print("start:", x.start()) print("end:", x.end()) <re.Match object; span=(28, 33), match='Spain'> span: (28, 33) string: Mr Jain enjoyed the rain in Spain. group: Spain start: 28 end: 33

The "finditer()" function

>>> import re >>> s = "Mr Jain enjoyed the rain in Spain with Ms Jain." >>> re.finditer('ai', s) <callable_iterator object at 0x000001899B48A9B0> >>> >>> fi = re.finditer('ai', s) >>> for i in fi: ... print(i.span()) ... (4, 6) (21, 23) (30, 32) (43, 45) >>> Tags: Technology,Python,Anaconda,Natural Language Processing,

Thursday, June 3, 2021

Petril Beta - 10 (Combination Medicine)


Petril Beta 10 Tablet
Prescription: Required
MANUFACTURER: Micro Labs Ltd
SALT COMPOSITION: Clonazepam (0.25mg) + Propranolol (10mg)
STORAGE: Store below 30°C

Introduction
Petril Beta 10 Tablet is a prescription medicine used to treat anxiety disorder. It calms the brain by decreasing abnormal and excessive activity of the nerve cells. It blocks the action of certain chemical messengers on the heart and blood vessels. This reduces heart rate and blood pressure.

Petril Beta 10 Tablet should be taken on an empty stomach. However, it is advised to take it at the same time each day as this helps to maintain a consistent level of medicine in the body. Take this medicine in the dose and duration advised by your doctor as it has high habit-forming potential. If you miss a dose of this medicine, take it as soon as you remember. Finish the full course of treatment even if you feel better. It is important not to stop taking this medicine suddenly as it may cause withdrawal symptoms. Avoid consuming alcohol while taking this medicine as this may reduce its effectiveness.

Some common side effects of this medicine include confusion, memory impairment, slow heart rate, tiredness, and nightmare.  It may also cause dizziness and sleepiness. So, do not drive or do anything that requires mental focus until you know how this medicine affects you.  It is important to inform your doctor if you develop any unusual changes in mood or depression as this medicine may cause suicidal thoughts.

Take caution while taking medicine if you are suffering from liver disease. Your doctor should also know about all other medicines you are taking as many of these may make this medicine less effective or change the way it works. Inform your doctor if you are pregnant, planning pregnancy or breastfeeding.

BENEFITS OF PETRIL BETA TABLET

In Anxiety disorder
Petril Beta 10 Tablet stops your brain from releasing the chemicals that make you feel anxious so it can reduce the symptoms of excessive anxiety and worry. It can also reduce feelings of restlessness, tiredness, difficulty concentrating, feeling irritable and sleep problems that often come with Generalised Anxiety Disorder. Petril Beta 10 Tablet will therefore help you go about your daily activities more easily and be more productive. Keep taking this medicine even if you feel well. Stopping suddenly can cause serious problems.

SIDE EFFECTS OF PETRIL BETA TABLET

Most side effects do not require any medical attention and disappear as your body adjusts to the medicine. Consult your doctor if they persist or if you’re worried about them.

Common side effects of Petril Beta:

1. Confusion
2. Memory impairment
3. Drowsiness
4. Slow heart rate
5. Tiredness
6. Uncoordinated body movements
7. Nightmare
8. Cold extremities

HOW PETRIL BETA TABLET WORKS

Petril Beta 10 Tablet is a combination of two medicines: Clonazepam and Propranolol. 

% Clonazepam is a benzodiazepine. It works by increasing the action of GABA, a chemical messenger which suppresses the abnormal and excessive activity of the nerve cells in brain. 

% Propranolol is a beta blocker which blocks the action of certain chemical messengers on the heart and blood vessels. This reduces heart rate, blood pressure, and strain on the heart.
Tags: Medicine,Science,