Friday, May 12, 2023

Python 'math' Module, 'statistics' Module and Descriptive statistics using Pandas, NumPy, SciPy and StatsModels

Note: In this article we discuss three things:
1. math Module 
2. statistics Module 
3. Descriptive statistics using Pandas, NumPy, SciPy and StatsModels

Python math Module

Python has a built-in module that you can use for mathematical tasks.

The math module has a set of methods and constants.


Math Methods

Method Description
math.acos() Returns the arc cosine of a number
math.acosh() Returns the inverse hyperbolic cosine of a number
math.asin() Returns the arc sine of a number
math.asinh() Returns the inverse hyperbolic sine of a number
math.atan() Returns the arc tangent of a number in radians
math.atan2() Returns the arc tangent of y/x in radians
math.atanh() Returns the inverse hyperbolic tangent of a number
math.ceil() Rounds a number up to the nearest integer
math.comb() Returns the number of ways to choose k items from n items without repetition and order
math.copysign() Returns a float consisting of the value of the first parameter and the sign of the second parameter
math.cos() Returns the cosine of a number
math.cosh() Returns the hyperbolic cosine of a number
math.degrees() Converts an angle from radians to degrees
math.dist() Returns the Euclidean distance between two points (p and q), where p and q are the coordinates of that point
math.erf() Returns the error function of a number
math.erfc() Returns the complementary error function of a number
math.exp() Returns E raised to the power of x
math.expm1() Returns Ex - 1
math.fabs() Returns the absolute value of a number
math.factorial() Returns the factorial of a number
math.floor() Rounds a number down to the nearest integer
math.fmod() Returns the remainder of x/y
math.frexp() Returns the mantissa and the exponent, of a specified number
math.fsum() Returns the sum of all items in any iterable (tuples, arrays, lists, etc.)
math.gamma() Returns the gamma function at x
math.gcd() Returns the greatest common divisor of two integers
math.hypot() Returns the Euclidean norm
math.isclose() Checks whether two values are close to each other, or not
math.isfinite() Checks whether a number is finite or not
math.isinf() Checks whether a number is infinite or not
math.isnan() Checks whether a value is NaN (not a number) or not
math.isqrt() Rounds a square root number downwards to the nearest integer
math.ldexp() Returns the inverse of math.frexp() which is x * (2**i) of the given numbers x and i
math.lgamma() Returns the log gamma value of x
math.log() Returns the natural logarithm of a number, or the logarithm of number to base
math.log10() Returns the base-10 logarithm of x
math.log1p() Returns the natural logarithm of 1+x
math.log2() Returns the base-2 logarithm of x
math.perm() Returns the number of ways to choose k items from n items with order and without repetition
math.pow() Returns the value of x to the power of y
math.prod() Returns the product of all the elements in an iterable
math.radians() Converts a degree value into radians
math.remainder() Returns the closest value that can make numerator completely divisible by the denominator
math.sin() Returns the sine of a number
math.sinh() Returns the hyperbolic sine of a number
math.sqrt() Returns the square root of a number
math.tan() Returns the tangent of a number
math.tanh() Returns the hyperbolic tangent of a number
math.trunc() Returns the truncated integer parts of a number

Math Constants

Constant Description
math.e Returns Euler's number (2.7182...)
math.inf Returns a floating-point positive infinity
math.nan Returns a floating-point NaN (Not a Number) value
math.pi Returns PI (3.1415...)
math.tau Returns tau (6.2831...)
Some of these methods have been seen very frequently in our work. These include:

math.ceil(): Rounds a number up to the nearest integer
math.floor(): Rounds a number down to the nearest integer
math.factorial(): Returns the factorial of a number
math.comb(): Returns the number of ways to choose k items from n items without repetition and order
math.degrees(): Converts an angle from radians to degrees
math.radians(): Converts a degree value into radians
math.gcd(): Returns the greatest common divisor of two integers
math.dist(): Returns the Euclidean distance between two points (p and q), where p and q are the coordinates of that point

Python statistics Module

Averages and measures of central location

These functions calculate an average or typical value from a population or sample.

mean()

Arithmetic mean (“average”) of data.

fmean()

Fast, floating point arithmetic mean, with optional weighting.

geometric_mean()

Geometric mean of data.

harmonic_mean()

Harmonic mean of data.

median()

Median (middle value) of data.

median_low()

Low median of data.

median_high()

High median of data.

median_grouped()

Median, or 50th percentile, of grouped data.

mode()

Single mode (most common value) of discrete or nominal data.

multimode()

List of modes (most common values) of discrete or nominal data.

quantiles()

Divide data into intervals with equal probability.

Measures of spread

These functions calculate a measure of how much the population or sample tends to deviate from the typical or average values.

pstdev()

Population standard deviation of data.

pvariance()

Population variance of data.

stdev()

Sample standard deviation of data.

variance()

Sample variance of data.

Statistics for relations between two inputs

These functions calculate statistics regarding relations between two inputs.

covariance()

Sample covariance for two variables.

correlation()

Pearson's correlation coefficient for two variables.

linear_regression()

Slope and intercept for simple linear regression.

NormalDist

NormalDist is a tool for creating and manipulating normal distributions of a random variable. It is a class that treats the mean and standard deviation of data measurements as a single entity. Normal distributions arise from the Central Limit Theorem and have a wide range of applications in statistics.

l = [13, 15, 16, 16, 19, 20, 20, 21, 22, 22, 25, 25, 25, 25, 30, 33, 33, 35, 35, 35, 36, 40, 45, 46, 52, 70]

# Sum of all elements

print(sum(l))

# Count of each items.

from collections import Counter 
print(Counter(l))

# Mean

import statistics as st

print(st.mean(l))

print("Median:", st.median(l))

# Mode

print(st.mode(l))

# Mid-range 

print(st.mean([max(l), min(l)]))

# Other statistical measures

print(st.quantiles(data = l, n = 4)) # [20.0, 25.0, 35.25]
print(st.stdev(l))
print(st.variance(l))

import pandas
l = [13, 15, 16, 16, 19, 20, 20, 21, 22, 22, 25, 25, 25, 25, 30, 33, 33, 35, 35, 35, 36, 40, 45, 46, 52, 70]
df = pandas.DataFrame(l, columns=['Numbers'])
sum = df['Numbers'].sum()
count_val = df['Numbers'].value_counts()
mode = df['Numbers'].mode().values.tolist()
midrange = (df['Numbers'].max() + df['Numbers'].min()) / 2

print("The sum of the given data using pandas ", sum)
print("\nThe count of values \n", count_val)
print("\nMean of the given data using pandas ", df['Numbers'].mean())
print("\nMedian of the given data using pandas ", df['Numbers'].median())
print("\nMode of the given data using pandas ", mode[0])
print("\nMidrange of the given data using pandas:", midrange)
print("\nStandard deviation for given data using pandas:", df['Numbers'].std())
print("\nVariance for given data using pandas:", df['Numbers'].var())
print("\nQuantiles\n", df['Numbers'].quantile([0.25,0.50,0.75]))
print("\n\n")

import numpy as np

data=np.array(l)
print("Using NumPy\n")
unique_values, counts = np.unique(data, return_counts=True)
quantiles=np.percentile(data,[25,50,75])
print("Sum ",np.sum(data))
print("\nCount of values \n")
for value, count in zip(unique_values, counts):
    print( value, count)   
print("Mean :",np.mean(data))
print("\nMedian:",np.median(data))
print("\nMode:",np.argmax(np.bincount(data)))    
print("\nStandard deviation",np.std(data))
print("\nVariance :",np.var(data))
print("\nQuantiles \n")
print(quantiles[0],quantiles[1],quantiles[2])
print("\n\n")


from scipy import stats 

print("Using SciPy\n")
mode=stats.mode(data)
print("Mode: ", mode.mode[0])

# For count--> scipy.stats.itemfreq()
# Other statistical measures similar to numpy



$ python statistical_summary.py 
774
Counter({25: 4, 35: 3, 16: 2, 20: 2, 22: 2, 33: 2, 13: 1, 15: 1, 19: 1, 21: 1, 30: 1, 36: 1, 40: 1, 45: 1, 46: 1, 52: 1, 70: 1})
29.76923076923077
Median: 25.0
25
41.5
[20.0, 25.0, 35.25]
13.158442741624686
173.14461538461538
The sum of the given data using pandas  774

The count of values 
25    4
35    3
16    2
20    2
22    2
33    2
13    1
40    1
52    1
46    1
45    1
30    1
36    1
15    1
21    1
19    1
70    1
Name: Numbers, dtype: int64

Mean of the given data using pandas  29.76923076923077

Median of the given data using pandas  25.0

Mode of the given data using pandas  25

Midrange of the given data using pandas: 41.5

Standard deviation for given data using pandas: 13.158442741624686

Variance for given data using pandas: 173.14461538461538

Quantiles
0.25    20.25
0.50    25.00
0.75    35.00
Name: Numbers, dtype: float64



Using NumPy

Sum  774

Count of values 

13 1
15 1
16 2
19 1
20 2
21 1
22 2
25 4
30 1
33 2
35 3
36 1
40 1
45 1
46 1
52 1
70 1
Mean : 29.76923076923077

Median: 25.0

Mode: 25

Standard deviation 12.902914674622618

Variance : 166.4852071005917

Quantiles 

20.25 25.0 35.0



Using SciPy

/home/ashish/Desktop/statistical_summary.py:90: FutureWarning: Unlike other reduction functions (e.g. `skew`, `kurtosis`), the default behavior of `mode` typically preserves the axis it acts along. In SciPy 1.11.0, this behavior will change: the default value of `keepdims` will become False, the `axis` over which the statistic is taken will be eliminated, and the value None will no longer be accepted. Set `keepdims` to True or False to avoid this warning.
    mode=stats.mode(data)
Mode:  25

Tags: Technology,Python,Mathematical Foundations for Data Science,

BITS WILP Information Retrieval Assignment 2017-H1


Information Retrieval (SS ZG537)
Assignment
Second Semester 2016-2017

Total Marks: 10

Due Date: 30/3/2017

Objective:
Select a research paper [between the year 2010-2017] of your choice related to any of the concepts taught in the class, read, understand and summarize in your own words.

Note: Theoretical or implementation papers are encouraged while Survey papers are not entertained unless it has a considerable substance.

Instructions for preparing the report:
1. Summarize the contents in your own words in a condensed form which must include the following:
Problem statement
Solution approach
Architecture (If any)
Results
Conclusion

2. You are open to find out a problem / drawback/ limitations of the paper and suggest improvements for the approach given in the paper.

3. Prepare a report of 3-6 pages.

4. You may refer to IEEE, ACM or any other journal/conference/white papers.

5. Attach the original paper in pdf format while submitting.

6. Individual submission is to be made.

Marks distribution:
Marks will be awarded for genuine efforts only (You are not supposed to copy-paste the contents from the file paper (except diagrams and results tables etc).

BITS WILP Information Retrieval Assignment 2023-H1 (Solution) - Assessing Viewpoint Diversity in Search Result Rankings


1. Problem. What is the problem/study that the paper addresses?

Ans:
Assessing Viewpoint Diversity in Search Results Using Ranking Fairness Metrics.
The way pages are ranked in search results influences whether the users of search engines are exposed to more homogeneous, or rather to more diverse viewpoints. 

However, this viewpoint diversity is not trivial to assess. 

In this paper, researchers use existing and novel ranking fairness metrics to evaluate viewpoint diversity in search result rankings. 

The researchers conducted a controlled simulation study that shows how ranking fairness metrics can be used for viewpoint diversity, how their outcome should be interpreted, and which metric is most suitable depending on the situation. 

2. Related Work. What are other work(s) that solve similar problem(s)/conduct similar study?

Ans:
Diversity in search result rankings is not a novel topic. Several methods have been proposed to measure and improve diversity in ranked lists of search results [1; 2; 9; 20; 21].

Unlike previous methods, which aim to balance relevance (e.g., in relation to a user query) and diversity (e.g., in relation to user intent), this research paper delves deeper into the notion of diversity. This research paper specifically focuses on ranking fairness (as in [27]) for assessing viewpoint diversity, which originates from the field of fair machine learning.

[1] A. Abid, N. Hussain, K. Abid, F. Ahmad, M. S. Farooq, U. Farooq, S. A. Khan, Y. D. Khan, M. A. Naeem, and N. Sabir. A survey on search results diversification techniques. Neural Comput. Appl., 27(5):1207–1229, 2015.

[2] R. Agrawal, S. Gollapudi, A. Halverson, and S. Ieong. Diversifying search results. Proc. 2nd ACM Int. Conf. Web Search Data Mining, WSDM’09, pages 5–14, 2009.

[9] C. L. Clarke, M. Kolla, G. V. Cormack, O. Vechtomova, A. Ashkan, S. Büttcher, and I. MacKinnon. Novelty and diversity in information retrieval evaluation. ACM SIGIR 2008 - 31st Annu. Int. ACM SIGIR Conf. Res. Dev. Inf. Retrieval, Proc., pages 659–666, 2008.

[20] T. Sakai and R. Song. Evaluating diversified search results using per-intent graded relevance. SIGIR’11 Proc. 34th Int. ACM SIGIR Conf. Res. Dev. Inf. Retr., pages 1043–1052, 2011.

[21] T. Sakai and Z. Zeng. Which Diversity Evaluation Measures Are “ Good ”? In SIGIR’19, pages 595–604, 2019.

[27] K. Yang and J. Stoyanovich. Measuring fairness in ranked outputs. In Proc. 29th Int. Conf. Sci. Stat. Database Manag., SSDBM ’17, pages 1–6, New York, NY, USA, 2017. Association for Computing Machinery.

3. Difference from Related Work. How is this paper different from other techniques mentioned in the related work section? What is new about their approach?

Ans:

(1) Unlike previous methods, which aim to balance relevance (e.g., in relation to a user query) and diversity (e.g., in relation to user intent), this research paper delves deeper into the notion of diversity. This research paper specifically focuses on ranking fairness (as in [27]) for assessing viewpoint diversity, which originates from the field of fair machine learning.

(2) Related work referred presents ideas and solutions worked towards ranking fairness and the mitigation of bias, while this research paper aims to to quantify the degree of viewpoint diversity in search result rankings.


4. Methodology. Summarize the method(s) proposed in the paper.


Ans:
Binomial viewpoint fairness. One aim for viewpoint diversity may be to treat one specific viewpoint, e.g., a minority viewpoint, fairly.

Multinomial viewpoint fairness. Another aim when evaluating viewpoint diversity may be that all viewpoints are covered fairly.

Evaluating statistical parity. In this paper, we use ranking fairness metrics to assess viewpoint diversity in search result rankings. These are based on the notion of statistical parity, which is present in a ranking when the viewpoints that documents express do not a↵ect their position in the ranking. However, we are only given the ranking and viewpoint per document and cannot assess the ranking algorithm directly. Statistical parity thus needs to be approximated.

Discounting the ranking fairness computation. User attention depletes rapidly as the ranks go up [13; 18]. For example, in a regular web search, the majority of users may not even view more than 10 documents. This means that a measure of viewpoint diversity needs to consider the rank of documents, and not just whether viewpoints are present.

Normalization. When evaluating and comparing metrics, it is useful if they all operate on the same scale. We thus only consider normalized ranking fairness metrics.

5. Datasets. Did the paper use any datasets for their experiments? Summarize them. To simulate different ranking scenarios, we first generate three synthetic sets S1, S2, and S3 to represent different viewpoint distributions. The items in each set simulate viewpoint labels for 700 documents (i.e., to enable a simple balanced distribution over seven viewpoints) and are distributed as shown in Table 4. Whereas S1 has a balanced distribution of viewpoints, S2 and S3 are skewed towards supporting viewpoints.8 We use S1, S2, and S3 to simulate both binomial and multinomial viewpoint fairness.
6. Experiments. Briefly describe what experiments were performed. Sampling. We create rankings of the viewpoint labels in S1, S2, and S3 by conducting a weighted sampling procedure. To create a ranking, viewpoint labels are gradually sampled from one of the three sets without replacement to fill the individual ranks. Each viewpoint label in the set is assigned one of two different sample weights that determine the labels’ probability of being drawn. These two sample weights are controlled by the ranking bias parameter alpha and given by:
7. Results. What is the lesson learned from the experiments? We adapted existing ranking fairness metrics to measure binomial viewpoint fairness and proposed a novel metric that evaluates multinomial viewpoint fairness. We find that despite some limitations, the metrics reliably detect viewpoint diversity in search results in our controlled scenarios. Crucially, our simulations show how these metrics can be interpreted and their relative strengths. This lays the necessary groundwork for future research to assess viewpoint diversity in actual search results. We plan to perform such evaluations of existing web search engines concerning highly debated topics and upcoming elections. Such work would not only provide tremendous insight into the current state of viewpoint diversity in search result rankings but pave the way for a greater understanding of how search result rankings may affect public opinion. 8. Three major strengths of the paper Strength 1: The paper builds on top of past research by bringing in the idea of quantifying viewpoint diversity in rankings. Strength 2: The approach to problem solving is purely statistical and can be safely relied upon. Strength 3: Experiments are easily repeatable in lab. 9. Three major weaknesses of the paper Weakness 1: Application of the reseach is limited by the nature of overall distribution of protected and non-protected items in the ranking. Also, choice of metric depends also on the ranking bias. 5.3: Caveats and Limitations We note that our simulation study is limited in at least three important ways. First, we consider a scenario in which documents have correctly been assigned multinomial viewpoint labels. This allows us to study their behavior in a controlled setting. In reality, existing viewpoint labeling methods are prone to biases and issues of accuracy. Current opinion mining techniques are still limited in their ability to assign such labels [25] and crowdsourcing viewpoint annotations from human annotators can be costly and also prone to biases and variance [26]. Second, we assume that any document in a search result ranking can be assigned some viewpoint label concerning a given disputed topic. It is realistically possible for a document to contain several, or even all available viewpoints (e.g., a debate forum page). In these cases, assigning an overarching viewpoint label might oversimplify the nuances in viewpoints that exist within rankings and thereby not leading to a skewed assessment of viewpoint diversity in the search result ranking. Future work could look into best practices of assigning viewpoint labels to documents. Third, our simulation of multinomial viewpoint fairness included only one specific case in which one viewpoint is treated differently compared to the other six. There are other scenarios where multinomial viewpoint fairness could become relevant. These scenarios di↵er in how many viewpoint categories there are, how many items are advantaged in the ranking, and to what degree. Simulating all of these potential scenarios is beyond the scope of this paper. Future work could however explore how metrics such as nDJS behave in such scenarios. 10. Scope of Work. How can you/your employer benefit from this work? If not, in which domain can this be applied? The research is relevant to a team working in the domain of search engines and ranked information retrieval.

BITS WILP Information Retrieval Assignment 2023-H1 (Problem)


WILP Assignment 2nd Semester 2022-2023
(35 pts)
Prajna Upadhyay
April 2023

#1 Research Paper Review Report Assignment
The goal is to read, understand, and critically analyze the given paper. The review report is made up of the following sections. Each section should contain at most 5 sentences (worth 3 marks) and 8 sentences (worth 5 marks).

1. Problem. What is the problem/study that the paper addresses?

2. Related Work. What are other work(s) that solve similar problem(s)/conduct similar study?

3. Difference from Related Work. How is this paper different from other techniques mentioned in the related work section? What is new about their approach?

4. Methodology. Summarize the method(s) proposed in the paper.

5. Datasets. Did the paper use any datasets for their experiments? Summarize them.

6. Experiments. Briefly describe what experiments were performed.

7. Results. What is the lesson learned from the experiments?

8. Three major strengths of the paper

9. Three major weaknesses of the paper

10. Scope of Work. How can you/your employer benefit from this work? If not, in which domain can this be applied?

#2 Grading

You will be evaluated based on your overall understanding of the paper. Strict plagiarism checking will be done. The severity of plagiarism determines how much you will be penalized. The section-wise marks allocation is shown in

#3 Papers to review 3 papers are available for review. You can choose one of them. All of them are related to search and ranking. 1. Assessing Viewpoint Diversity in Search Results Using Ranking Fairness Metrics, Link: https://dl.acm.org/doi/pdf/10.1145/3468507.3468515 2. This Is Not What We Ordered: Exploring Why Biased Search Result Rankings Affect User Attitudes on Debated Topics, Link: https://dl.acm.org/doi/10.1145/3404835.3462851 3. This Item Might Reinforce Your Opinion, Link: https://dl.acm.org/doi/10.1145/3465336.3475101 #4 What will you submit Each student will submit one PDF file containing the review report. Both handwritten and typed summaries will be accepted.

Thursday, May 11, 2023

14 Problems on lists in Python

"""
1.
Create a list of five fruits: apple, banana, orange, kiwi, grapes.

2.
Extend this list of fruits to add five vegetables to it: potato, tomato, onion, capsicum, beans.

3.
Append one more vegetable to it: brinjal

4. 
Remove 'capsicum' from this list.

5.
Create a new list without bringing in any vegetable or fruit whose first letter of name is 'b'.

6.
Remove first fruit and first vegetable from this list.

7.
Pop the third item.

8.
Reverse the list.

9. 
Sort the list.

10.
Clear all items from the list.

11.
Delete the list completely.

12. 
What is the difference between .remove() and .pop()?

13.
How do you check if a list contains an element? Show that list of fruits contain the apple.

14.
What is the difference between append and extend?
"""

# Solutions


l = ['apple', 'banana', 'orange', 'kiwi', 'grapes']

v = ['potato', 'tomato', 'onion', 'capsicum', 'beans']

l.extend(v)

print(l)

l.append('brinjal')

print(l)

l.remove('capsicum')

print(l)

m = [i for i in l if not i.startswith('b')]

print(m)

l.remove('apple')
l.remove('potato')

print(l)

l.pop(3)

print(l)

l.reverse()

print(l)

l.sort()

print(l)

l.clear()

print(l)

del l

# 12: remove() takes the item value. pop() takes the item index.

# 13

l = ['apple', 'banana', 'orange', 'kiwi', 'grapes']
print('apple' in l)

# 14: append() adds an element. extend() does the concatenation of two lists. 
Tags: Python,Technology,

Khichdi (Recipe)

1. Take daal and rice in a bowl.

Arhar daal : 0.25 bowl
Masur daal : 0.25 bowl
Half bowl daal. Half bowl chawal.

2. Wash the mixture three times with water.
3. Heat 3 table spoons of refined oil in a pressure cooker. 4. Fry 1 table spoon of jeera, and one salt spoon of haldi and one salt spoon of dhania powder. 5. Add salt as per taste. 6. Add 900 ml of water to the mixture. 7. Put the cooker on burner for five whistles.

Wednesday, May 10, 2023

Lists in Python

What is a list?

  • Lists are used to store multiple items in a single variable.
  • List items are:
  • - Ordered: items take order in which they are written in code
  • - Changeable: you can use the assignment operator to change the items
  • - And allow duplicate values
  • List items are indexed, the first item has index [0], the second item has index [1], the third item has index [2], so and so forth.

Indexing (Part 1)

  • # Accessing list items by using their index
  • # Note : index start from 0
  • # Note : Negative index start from -1
  • thislist = ["apple", "banana", "cherry"]
  • print(thislist[0])
  • print(thislist[1])
  • print(thislist[2])
  • print(thislist[-1]) # Prints the last element

Indexing (Part 2)

  • Using negative numbers as indices to write a slice.
  • x = ["apple", "banana", "orange", "watermelon", "cherry"]

print(thislist[-1]) # Prints the last element

print(thislist[len(thislist) - 1])

# Index “-1” is equivalent to index “len(thislist) – 1”.

print(thislist[-2]) # Prints the second last element

print(thislist[len(thislist) - 2])

print(thislist[-3]) # Prints the third last element

print(thislist[len(thislist) - 3])

Slicing (Part 1)

  • Slice syntax = [start index : end index : step (optional)]
  • Q: You are given that a list has 10 items.
  • Which all indices are covered by the slice [2:5]?
  • Ans: Three parts of the slice [2:5] are:
  • start index = 2
  • end index = 5
  • step = 1 (takes the default value as it is not mentioned)
  • Slicing is “exclusive” of end index, that means index 5 will not be a part of the slice [2:5].
  • That means indices covered are: 2, 3 and 4.

Slicing (Part 2)

  • What does this slice expand to - [:4]
  • Start index is not mentioned. That means start index takes the default value: 0
  • End index is given to be 4.
  • Step is not mentioned. Step takes the default value of ‘1’

Slicing (Part 3)

  • What does this slice expand to... [4:]
  • Start index is mentioned.
  • It has the value: 4
  • End index is not mentioned.
  • It has the default value of: len()
  • Step is not mentioned. Step takes the default value of ‘1’

Slicing (Part 4)

  • You are given a list of 10 elements.
  • Ques: Which all indices are present in slice... [2:10:2]
  • Ans:
  • Start index is 2. Why? Because it is the number mentioned before the first colon.
  • End index is 10.
  • ‘Step’ is mentioned after the second colon. Step has value 2.
  • So, 2 will come. After that, 4 will come. After that, 6 will come. After that, 8 will come. That is it, because it is exclusive of end index.

Slicing (Part 5)

  • A slice has three parts: start index, end index and step.
  • Default value of start index: 0
  • Default value of end index: len()
  • Default value of step: 1
  • Q: What does this [2:5] expand to?
  • [2:5:1]
  • Q: What does this [:4] expand to?
  • Here, we can see that we have a single colon. This means that we have assume default value for step = 1.
  • Because the number before colon is missing that has to be start index. And number after colon is: end index.
  • [0:4:1]
  • Q: What does this [2:] expand to?
  • Answer: [2:len():1]

Slicing (Part 6)

  • # Accessing multiple items by using a range of indexes
  • thislist = ["apple", "banana", "cherry", "orange", "kiwi", "melon", "mango"]
  • print(thislist[2:5]) # Inclusive of 2 and exclusive of 5
  • print(thislist[:4]) # From Begining to specified index
  • # Note "kiwi" not included in the result
  • # This slice [:4] -> [0:4:1]
  • print(thislist[2:])
  • # This slice [2:] -> [2:7:1]
  • # 7 because it is the length of the list.
  • # Using Negative indexes
  • print(thislist[-4:-1]) # Note - last item index value is -1 and this not included in result

Assignment of another list on a slice of list

  • With assignment operator, you can assign to an index and assign to a slice.
  • When you assign a longer list to a shorter slice, it increases the length of the list.
  • When you assign a shorter list to a longer slice, it decreases the length of the list.

Adding elements to a list

  • Insert(): Used to insert element at a specified index.
  • Takes two arguments. First argument is the index.
  • Append(): takes one argument. That argument is an element to be appended in the list.
  • Extend(): takes one argument but that argument is a list for us.
  • Here, usage is: mainlist.extend(listtoappend)
  • It is equivalent to: mainlist = mainlist + listtoappend
  • Note: They lead to increase in the length of the original list.

Removing items from a list

  • Remove(): takes one argument. And argument is the element itself.
  • For ex: if it is list of strings, the argument would be a string. If it is a list of integers, the argument would be an int.
  • Pop(): also takes one argument (defaults to ‘len()-1’ (which means the last element) if no argument is passed) but that argument is the index.
  • Del: using the keyword ‘del’ delete from a specified index.
  • Clear(): empties a list
>>> l = ['alpha', 'beta', 'gamma']
>>> l.remove('alpha')
>>> l
['beta', 'gamma']
>>> 
>>> 
>>> l.pop(0)
'beta'
>>> 
>>> l
['gamma']
>>> 
  

Problem

  • Q: Let the input list be: x = ["apple", "banana", "orange", "watermelon", "cherry"]
  • Show how you can reverse this list in three ways.

Solution

  • 1) Through slicing:
  • x[::-1]
  • 2) Using the built-in function:
  • list(reversed(x))
  • 3) Using method invocation:
  • x.reverse()

List Comprehension (Part 1)

  • Creating a new list from an existing one:

# Creating a new list from an existing one

l = ["apple", "banana", "cherry", "guava"]

n = []

for i in l:

n.append(i)

print(n)

['apple', 'banana', 'cherry', 'guava']

# NOW USING LIST COMPREHENSION:

l = ["apple", "banana", "cherry", "guava"]

n = [ str(i) for i in l ]

print(n)

List Comprehension (Part 2)

# Syntax of list comprehension: [ some_function(i) for i in some_list ]

my_list = ["apple", "banana", "cherry", "guava"]

n = [ str(i) for i in my_list ]

print(n)

Output:

['apple', 'banana', 'cherry', 'guava']

Here:

some_function() is your: str()

some_list is your: my_list = ["apple", "banana", "cherry", "guava"]

Problem on List Comprehension

  • You have a list of 10 numbers.
  • [5, 2, 9, 1, 8, 3, 6, 0, 4, 7]
  • Create a new list by adding 5 to each of these numbers.

Solution

# Create a new list by adding 5 to each of these numbers.

l = [5, 2, 9, 1, 8, 3, 6, 0, 4, 7]

k = [i + 5 for i in l]

print(k)

[10, 7, 14, 6, 13, 8, 11, 5, 9, 12]

Problem 1 on: Assignment to a slice

thislist = ["apple", "banana", "cherry", "orange", "kiwi", "melon", "mango"]

thislist[1:3] = ['potato', 'tomato', 'brinjal']

What will be the output?

Solution 1 on: Assignment to a slice

thislist = ["apple", "banana", "cherry", "orange", "kiwi", "melon", "mango"]

len(thislist)

Out: 7

# What is being replaced?

thislist[1:3]

Out: ['banana', 'cherry']

thislist[1:3] = ['potato', 'tomato', 'brinjal']

thislist

Out: ['apple', 'potato', 'tomato', 'brinjal', 'orange', 'kiwi', 'melon', 'mango']

len(thislist)

8

Tags: Technology,Python,

Thursday, May 4, 2023

Brahmi

Brahmi (derived from the name of Lord Brahma and Goddess Saraswati) is a perennial herb most well known for its memory enhancing property.
Brahmi tea that is made by brewing Brahmi leaves helps to manage cold, chest congestion and bronchitis by clearing out the mucus from the air passages which helps ease breathing. It also reduces pain and inflammation in the throat and respiratory tracts due to its anti-inflammatory property. Taking Brahmi powder along with milk helps improve brain functions by preventing brain cell damage caused by free radicals due to its antioxidant property.

It is used as a memory enhancer and brain tonic for kids due to its property to improve cognition.
Applying Brahmi oil to the scalp helps prevent hair loss as it nourishes and provides strength to the hair. It also disinfects the skin and speeds up the healing process when applied externally.
Excessive intake of Brahmi should be avoided as it may cause nausea and dry mouth.

What are the synonyms of Brahmi?

Bacopa Monnieri, Babies tear, Bacopa, Herpestis monniera, Water hyssop, Sambarenu.

What is the source of Brahmi?

Plant Based

Benefits of Brahmi

What are the benefits of Brahmi for Age related memory loss? Modern Science View Brahmi may be useful in managing age-related memory loss due to the presence of antioxidants. It may reduce the damage caused because of free radicals and enhance learning and retaining potential in older people. Brahmi may also be useful in reducing the accumulation of a protein responsible for Alzheimer’s disease. Ayurvedic View Brahmi helps in managing age-related memory loss when used on a regular basis. According to Ayurveda, the nervous system is controlled by Vata. An imbalance of Vata leads to weak memory or poor mental alertness. Brahmi is useful to enhance memory and gives instant mental alertness. This is due to its Vata balancing and Medhya (improve intelligence) properties. What are the benefits of Brahmi for Irritable bowel syndrome? Modern Science View Brahmi has the property of managing intestinal spasms. It may provide temporary relief from the symptoms of irritable bowel syndrome (IBS), however, it does not treat IBS permanently. What are the benefits of Brahmi for Anxiety? Modern Science View Brahmi may be useful in managing anxiety due to its anxiolytic (anti-anxiety) property. It may reduce the symptoms of anxiety and mental fatigue while increasing memory span. Brahmi may also prevent neuroinflammation (inflammation of the nervous tissue) which is responsible for anxiety. Ayurvedic View Brahmi is useful to manage the symptoms of anxiety. According to Ayurveda, Vata governs all the movement and actions of the body and nervous system respectively. Anxiety is mainly due to Vata imbalance. Brahmi helps to balance Vata and gives a calming effect on the nervous system. What are the benefits of Brahmi for Epilepsy/Seizures? Modern Science View Brahmi is rich in antioxidants that protect the brain cells. During an epileptic attack, production and activity of certain genes and their proteins gets reduced. Brahmi stimulates these genes, proteins and pathways thereby reversing the probable cause and effects of epilepsy. Ayurvedic View Brahmi helps to manage the symptoms of epilepsy. In Ayurveda, epilepsy is termed as Apasmara. Epileptic patients experience episodes of seizures. A seizure is due to an abnormal electrical activity in the brain leading to uncontrollable and rapid body movements. This might even lead to unconsciousness. Epilepsy involves all the three doshas-Vata, Pitta, and Kapha. Brahmi helps to balance all the three doshas and reduces the episodes of seizures. Brahmi also helps to maintain healthy brain function because of Medhya (improve intelligence) property. What are the benefits of Brahmi for Asthma? Modern Science View Brahmi may be useful in managing asthma due to its antiasthmatic property. It relaxes the respiratory tract and also helps to manage allergic conditions. Ayurvedic View Brahmi helps to reduce the symptoms of asthma. According to Ayurveda, the main doshas involved in asthma are Vata and Kapha. The vitiated ‘Vata’ combines with deranged ‘Kapha dosha’ in the lungs causing obstruction in the respiratory passage. This results in difficulty in the breath. This condition is known as Swas Roga or Asthma. Brahmi helps to calm Vata-Kapha and removes excess mucus from the lungs. This gives relief from the symptoms of asthma. What are the benefits of Brahmi for Improving sexual performance? Modern Science View Brahmi may be useful in managing certain sexual problems. In males, it improves sperm quality and sperm concentration. In females, it may be useful in managing infertility. Brahmi may also stimulate sex drive. What are the benefits of Brahmi for Pain relief? Modern Science View Brahmi may be useful in managing chronic pains due to its analgesic and anti-inflammatory properties. It may also be useful in managing pain caused due to nerve damage or injury. Brahmi blocks the detection of pain by nerve cells thereby reducing pain. What are the benefits of Brahmi for Hoarseness of voice? Modern Science View Although enough scientific evidence is not available, in traditional medicine, Brahmi may be useful in managing hoarseness of voice. What are the benefits of Brahmi for Depression? Modern Science View Brahmi has neuroprotective, anxiolytic (anti-anxiety) and antidepressant properties. These properties may be useful in managing mental illnesses like anxiety, depression and insanity. Brahmi may be useful in promoting mental health, intellect and improving memory. Ayurvedic View Brahmi helps to reduce the symptoms of mental illness like anxiety and depression. According to Ayurveda the nervous system is controlled by Vata and imbalance of Vata causes mental illness. Brahmi helps in balancing Vata and controlling the symptoms of mental illness. Brahmi also maintains healthy brain function because of its Medhya (improve intelligence) property. How effective is Brahmi? Likely effective Age related memory loss Likely ineffective Irritable bowel syndrome Insufficient evidence Anxiety, Asthma, Depression, Epilepsy/Seizures, Hoarseness of voice, Improving sexual performance, Pain relief Precautions when using Brahmi Other Interaction scientific Modern Science View Brahmi may increase the level of thyroid hormone. So it is generally advised to monitor your TSH level while taking Brahmi along with thyroid drugs[6]. scientific Modern Science View Brahmi may interact with sedatives. So it is generally advised to consult your doctor while taking Brahmi along with sedatives[6]. scientific Modern Science View Brahmi may interact with liver functioning. So it is generally advised to monitor your liver functions while taking Brahmi along with hepatoprotective drugs[6]. scientific Modern Science View Brahmi may increase stomach and intestinal secretions. So it is generally advised to consult your doctor while taking Brahmi if you have stomach ulcers[5]. scientific Modern Science View Brahmi may increase the fluid secretion in lungs. So it is generally advised to consult your doctor while taking Brahmi if you have asthma or emphysema[5]. Patients with heart disease scientific Modern Science View Brahmi may decrease the heart rate. So it is generally advised to monitor your heart rate regularly while taking Brahmi[5]. Side Effects Important scientific Modern Science View 1. Dry mouth 2. Nausea 3. Thirst 4. Palpitations[6]. Recommended Dosage of Brahmi Brahmi Juice - 2-4 teaspoons once a day. Brahmi Churna - ¼-½ teaspoon twice a day. Brahmi Capsule - 1-2 capsules twice a day. Brahmi Tablet - 1-2 tablets twice a day. Brahmi Infusion - 3-4 teaspoons once or twice a day. How to use Brahmi 1. Brahmi Fresh Juice a. Take 2-4 teaspoons of Brahmi fresh juice. b. Add equal quantity of water to it and drink once a day before food. 2. Brahmi Churna a. Take ¼-½ teaspoon Brahmi churna. b. Swallow it with honey before or after lunch and dinner. 3. Brahmi Capsule a. Take 1-2 Brahmi capsule. b. Swallow it with milk before or after lunch and dinner. 4. Brahmi Tablet a. Take 1-2 Brahmi tablet. b. Swallow it milk before or after lunch and dinner. 5. Brahmi Cold Infusion a. Take 3-4 teaspoons Brahmi cold infusion. b. Add water or honey and drink before lunch and dinner. Benefits of Brahmi 1. Sunburn Brahmi is useful for fighting against sunburn. According to Ayurveda, Sunburn occurs due to the aggravation of Pitta dosha because of continuous exposure to the sun. Applying Brahmi oil gives an excellent cooling effect and reduces burning sensation. This is due to its Sita (cold) and Ropan (healing) nature. Tips: A. Brahmi oil i. Take 2-4 drops of Brahmi oil or as per your requirement. ii. Mix with coconut oil. iii. Apply on the affected area once or twice a day to get immediate relief from sunburn. B. Brahmi Powder i. Take 1-2 teaspoon Brahmi powder. ii. Mix with rose water and make a paste. iii. Apply it on the affected area for quick healing of sunburn. 2. Hair loss Brahmi oil helps to control hair fall and promote hair growth when applied to the scalp. This is because hair fall is mainly due to an aggravated Vata dosha in the body. Brahmi oil acts on hair fall by balancing Vata dosha. It also helps remove excessive dryness. This is due to its Snigdha (oily) and Ropan (healing) properties. 3. Headache A massage with the paste of Brahmi leaves or its oil on the head helps to reduce headache especially that starts in your temples and spreads to the central part of your head. This is because of Sita (cold) potency of Brahmi. It helps to remove Pitta aggravating factors and reduces headache. Tips: 1. Take 1-2 teaspoon of paste of fresh leaves of Brahmi. 2. Mix with water and apply on the forehead. 3. Leave for at least 1-2 hours. 4. Wash it with plain water. 5. Repeat this once or twice a day to get relief from a headache. Precautions when using Brahmi Allergy scientific Modern Science View Avoid the use of Brahmi or consult a doctor before taking Brahmi if you are allergic to it[6]. ayurvedic Ayurvedic View A paste or powder of Brahmi leaves should be used with milk or honey if your skin is hypersensitive. ayurvedic Ayurvedic View Brahmi oil should be used after diluting with coconut oil before applying on the skin or scalp. Recommended Dosage of Brahmi Brahmi Juice - 1-2 teaspoon or as per your requirement. Brahmi Oil - ½-1 teaspoon or as per your requirement. Brahmi Paste - ½-1 teaspoon or as per your requirement. Brahmi Powder - ½-1 teaspoon or as per your requirement. How to use Brahmi 1. Brahmi Paste with Rose Water a. Take ½-1 teaspoon of Brahmi fresh paste. b. Mix it with rose water and apply on the face. c. Let it sit for 4-6 minutes. d. Wash thoroughly with plain water. e. Use this remedy 1-3 times a week. 2. Brahmi Oil a. Take ½-1 teaspoon of Brahmi oil. b. Massage gently on the scalp and hair. c. Repeat this 1 to 3 times a week. Frequently asked questions Q. What are the chemical constituents of Brahmi? scientific Modern Science View Major alkaloids of Brahmi are Brahmine and Saponins such as Bacposide A and B which improve the nootropic function (agents that enhance memory, creativity and motivation). This makes it Brahmi a good brain tonic[7]. Q. What are the various forms of Brahmi that are available in the market? scientific Modern Science View Brahmi is available in the market in the following forms: 1. Oil 2. Juice 3. Powder(Churna) 4. Tablet 5. Capsule 6. Sharbat Q. Can I take Brahmi on an empty stomach? scientific Modern Science View Yes, Brahmi can be taken on an empty stomach. In fact taking Brahmi on an empty stomach is even better as it aids better absorption. Q. Can Brahmi be taken with milk? scientific Modern Science View Yes, Brahmi can be taken with milk. Adding Brahmi to milk makes it a good tonic for the brain. This is due to its cooling effects. Q. Can Brahmi and Ashwagandha taken together? scientific Modern Science View Yes, Brahmi and Ashwagandha can be taken together. This combination works to boost the brain activity. ayurvedic Ayurvedic View Yes, Brahmi and Ashwagandha can take together because both help to maintain healthy function of the brain if your digestive is good otherwise these might increase your digestive problem. Q. Is Brahmi good for hair? ayurvedic Ayurvedic View Brahmi helps to control hair fall and enhance hair growth due to its Rasayana (rejuvenating) properties. Brahmi also has Sita (cold) potency and helps to balance excessive Pitta, the main reason behind hair problems.
Tags: Medicine,Ayurveda,

Suhagra 50

Suhagra 50 Tablet
Prescription Required
Manufacturer/ Marketer
Cipla Ltd
SALT COMPOSITION
Sildenafil (50mg)
Storage
Store below 30°C

Product introduction
Suhagra 50 Tablet is a prescription medicine used to treat erectile dysfunction (impotence) in men. It works by increasing blood flow to the penis. This helps men to get or maintain an erection. It belongs to a group of medicines known as phosphodiesterase type 5 (PDE 5) inhibitors.

Suhagra 50 Tablet may be taken on an empty stomach or with a meal. It should be strictly taken as advised by your doctor. You should take about 1 hour before you plan to have sex. The amount of time it takes to work varies from person to person, but it normally takes between 30 minutes and 1 hour. This medicine will only help you to get an erection if you are sexually stimulated. However, you should not take this medicine if you do not have erectile dysfunction. It should not be taken more than once a day.

The most common side effects of this medicine are flushing (sense of warmth), headache, dizziness, blurred vision, muscle pain, stomach upset, and rash. Talk to your doctor if any of the side effects bother you or do not go away.

This medicine is not intended for use by women and men should avoid using any other medicines to treat impotence without talking to a doctor first. It can be dangerous to take it along with medicines called nitrates (often given for chest pain or angina). Do not take this medicine if you have severe heart or liver problems, have recently had a stroke or heart attack or if you have low blood pressure. Let your doctor know if you suffer from these or any other health problems before taking it. You should not drive if this medicine makes you feel dizzy. Avoid drinking alcohol while taking this medicine as it increases the chances of side effects.
Uses of Suhagra Tablet

    Treatment of Erectile dysfunction

Benefits of Suhagra Tablet
In Treatment of Erectile dysfunction
Suhagra 50 Tablet belongs to a group of medicines called PDE5 inhibitors. It works by relaxing the blood vessels in your penis. This allows blood to flow into the penis and produce an erection when sexually aroused. This medicine will only help get an erection if you are sexually stimulated. It is very effective but needs to be taken at least 30 minutes before sexual activity.

Do not take this medicine if you also take medicines called nitrates (often given for chest pain).
Side effects of Suhagra 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 Suhagra

    Flushing (sense of warmth in the face, ears, neck and trunk)
    Headache
    Stiffness
    Nosebleeds
    Blurred vision
    Indigestion
    Muscle pain
    Upset stomach
    Rash

How to use Suhagra Tablet
Take this medicine in the dose and duration as advised by your doctor. Swallow it as a whole. Do not chew, crush or break it. Suhagra 50 Tablet may be taken with or without food, but it is better to take it at a fixed time.
How Suhagra Tablet works
Suhagra 50 Tablet is a phosphodiesterase-5 (PDE-5) inhibitor. It works by relaxing the blood vessels in your penis, thereby increasing blood flow into the penis on sexual stimulation. This helps you achieve and maintain a hard, erect penis suitable for sexual activity.
Safety advice
warnings
Alcohol
UNSAFE
It is unsafe to consume alcohol with Suhagra 50 Tablet.
warnings
Pregnancy
CONSULT YOUR DOCTOR
Information regarding the use of Suhagra 50 Tablet during pregnancy is not available. Please consult your doctor.
warnings
Breast feeding
CONSULT YOUR DOCTOR
Information regarding the use of Suhagra 50 Tablet during breastfeeding is not available. Please consult your doctor.
Use of Suhagra 50 Tablet is not indicated in women.
warnings
Driving
UNSAFE
Suhagra 50 Tablet may decrease alertness, affect your vision or make you feel sleepy and dizzy. Do not drive if these symptoms occur.
warnings
Kidney
SAFE IF PRESCRIBED
Suhagra 50 Tablet is safe to use in patients with kidney disease. No dose adjustment of Suhagra 50 Tablet is recommended.
However, inform your doctor if you have any underlying kidney disease. A lowering of dose may be considered if it is not well-tolerated.
warnings
Liver
CAUTION
Suhagra 50 Tablet should be used with caution in patients with severe liver disease. Dose adjustment of Suhagra 50 Tablet may be needed. Please consult your doctor.
There is limited information available on the use of Suhagra 50 Tablet in patients with severe liver disease.
What if you forget to take Suhagra Tablet?
If you miss a dose of Suhagra 50 Tablet, take it as soon as possible. However, if it is almost time for your next dose, skip the missed dose and go back to your regular schedule. Do not double the dose.
All substitutes
For informational purposes only. Consult a doctor before taking any medicines.
Suhagra 50 Tablet
₹22.75/Tablet
Vigron 50mg Tablet
Agron Remedies Pvt Ltd
₹1.1/tablet
95% cheaper
Eriacta 50mg Tablet
Sun Pharmaceutical Industries Ltd
₹2.28/tablet
90% cheaper
Vigore 50 Red Tablet
Zydus Healthcare Limited
₹14.5/tablet
36% cheaper
Sexigra 50mg Tablet
Intas Pharmaceuticals Ltd
₹18/tablet
21% cheaper
Stimulo 50 Tablet
Auspharma Private Limited
₹19.25/tablet
15% cheaper
View all substitutes
Quick tips
video img
play img

    You have been prescribed Suhagra 50 Tablet for the treatment of erectile dysfunction.
    It is best to take it an hour before sexual intercourse. But, you can take it anytime between 30 minutes and 4 hours before sexual activity.
    Do not take it more than once a day.
    Seek medical attention if the erection persists for more than 4 hours after sexual intercourse.
    Do not use Suhagra 50 Tablet if you have recently taken nitrates (medicines used in angina or chest pain).
    Do not take it if you have had a heart attack in the past 3 months, or stroke or heart failure in the past 6 months.

Fact Box
Chemical Class
Benzenesulfonamide Derivative
Habit Forming
No
Therapeutic Class
SEX STIMULANTS REJUVENATORS
Action Class
Phosphodiesterase-V inhibitors

Interaction with drugs

Taking Suhagra with any of the following medicines can modify the effect of either of them and cause some undesirable side effects Nitroglycerin Brand(s): Leonite, Isonit GTN, Nitrogal Life-threatening Isosorbide Dinitrate Brand(s): Isocrate, Cardicap, Sorbidine Life-threatening Isosorbide Mononitrate Brand(s): Monopark, Isotrate, Angitrate Life-threatening Nicorandil Brand(s): Lorandil Life-threatening
Tags: Medicine,

Anabel-CT Gel

Anabel-CT Gel

Manufacturer/ Marketer
Group Pharmaceuticals Ltd

SALT COMPOSITION
Choline Salicylate (8.7% w/w) + Lidocaine (2% w/w)

Storage
Store below 30°C

Preservative
Benzalkonium chloride

Product introduction
Anabel-CT Gel is a combination of two medicines is used to treat mouth ulcers. It also reduces the pain, swelling, redness, and burning sensation of the ulcers.

Anabel-CT Gel should be used as directed by your doctor and use it in the dose and duration advised by your doctor. Apply it only in the mouth with clean hands. Do not use it more than the recommended dose.

This medicine is generally safe and does not cause any side effects. However, if you experience any allergic reactions such as itching, swelling, rashes, etc., you should consult the doctor immediately.

Uses of Anabel-CT Dental Gel

    Treatment of Mouth ulcers

Benefits of Anabel-CT Dental Gel
In Treatment of Mouth ulcers
Mouth ulcers are small painful sores on inner lips, gums, tongue, roof of the mouth or throat that may interfere with eating, drinking and even talking. Anabel-CT Gel blocks chemicals in our brain that are responsible for pain sensation and inflammation. Therefore it provides relief from pain, discomfort and symptoms of inflammation such as redness, swelling or burning sensation due to mouth ulcers. This makes it easier for you to go about your daily activities. Continue using it as advised by the doctor to get maximum benefit.
Side effects of Anabel-CT Dental Gel
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 Anabel-CT

    No common side effects seen

How to use Anabel-CT Dental Gel
This medicine is for external use only. Use this medicine in the dose and duration as advised by your doctor.
How Anabel-CT Dental Gel works
Anabel-CT Gel is a combination of two medicines: Choline Salicylate and Lidocaine. Choline Salicylate is a non-steroidal anti-inflammatory drug (NSAID). It works by blocking the release of certain chemical messengers (prostaglandins) which cause pain and inflammation (redness and swelling). Lidocaine is a local anesthetic. It works by blocking pain signals from the nerves to the brain which decreases the pain sensation.

    Anabel-CT Gel helps relieve pain and inflammation caused by mouth ulcers, sore gums and denture irritation.
    Apply it over the affected area with a clean fingertip, three to four times a day or as directed by your doctor.
    Stop using this medicine and inform your doctor if any irritation occurs.
    If symptoms persist for more than seven days, consult your doctor.

Fact Box

Habit Forming No Therapeutic Class STOMATOLOGICALS
Tags: Medicine,

Smyle Mouth Ulcer Gel

Smyle is a mouth ulcer gel for topical application with astringent & anti-inflammatory properties. It provides instant relief from mouth ulcer pain. It also provides antiseptic analgesic & deodorant properties.Key ingredients in smyle mouth ulcer gel are: 
khadir, 
irimed, 
tagar, 
rasana, 
kushtha,
lodhra, 
yashtimadhu, 
karpoor and 
sharkara. 

Being ayurvedic it is also absolutely safe and has no side effects.

It is used in treatment of indications like mouth ulcer, food burns, sores caused by braces and dentures. It’s also an effective remedy for smoker’s bad breath and sores caused by chewing of tobacco.
    
Directions for use: Apply Smyle gel in the inside of mouth on the ulcers directly. It has a nice minty taste and the pain reduces on application. It is a jelly type paste so can be a bit difficult to spread. Sometimes you cannot put your fingers to certain parts of your mouth. Apply the Smyle gel a few times a day for just two to three days.
    
Use under medical supervision.
Tags: Medicine,

Wednesday, May 3, 2023

5 Problems on strings (Using Python)

1: Print every second character of a string using for-loop

name = "Johanth Yada" # Variable declaration # What a string is? A string is a list of characters that we can iterate. # We iterate over a sequence using the "in" keyword. # for i in name: # print(i) # USING INTERATION OR FOR-LOOP cntr = 1 # This is because we need to pick every second character only. To keep a track of our characters in the string. for i in name: if(cntr % 2 == 0): print(i) cntr += 1 print("----------") # STRING INDEXING print(name[1 : len(name) : 2]) # start index (0), end index (length - 1), step (1) # Stings indexing starts from 0. And the first character we wanted was on index number "1". names = "Johanth Yada, Shaurya" # STRING INDEXING print(names[5 : len(names) : 2]) # Stings indexing starts from 0. And the first character we wanted was on index number "1".

2: Reverse the order of words in a given string

# Python3 program to reverse a string # s = input() s = "i like this program very much" words = s.split(' ') string = [] for word in words: string.insert(0, word) print(" ".join(string))

Version 2

# input string string = "i like this program very much" # spliting words in the given string using slicing reverse the words s = string.split()[::-1] # joining the reversed string and printing the output print(" ".join(s))

3: Check whether a given number is divisible by 7

# Using Modulo n=371 # the above input can also be given as n=input() -> taking input from user # finding given number is divisible by 7 or not if int(n)%7==0: print("divisible") else: print("Not divisible") # Using divide and multiply import math n = 48 quo = math.floor(n/7) # int() was not explicit that we needed a floor value. if quo*7 == n: print("Divisible") else: print("Not Divisible")

4: Check if given String is Pangram or not

test_pangram_positive = [ "The quick brown fox jumps over the lazy dog.", "Waltz, bad nymph, for quick jigs vex.", "Glib jocks quiz nymph to vex dwarf.", "Sphinx of black quartz, judge my vow.", "How quickly daft jumping zebras vex!", "The five boxing wizards jump quickly.", "Jackdaws love my big sphinx of quartz.", "Pack my box with five dozen liquor jugs." ] test_pangram_negative = [ "My name is Ashish.", "I love programming.", "Am from Delhi and brown fox jumps over the dog." ] def check_pangram(in_str): in_str = in_str.lower() in_str = [x for x in in_str if x.isalpha()] in_str = set(in_str) ret_val = False if(len(in_str) == 26): ret_val = True return ret_val for i in test_pangram_positive: print(check_pangram(i)) for i in test_pangram_negative: print(check_pangram(i))

Version 2

s = "The quick brown fox jumps over the lazy boy." s = s.lower() new_str = "" for i in s: if i.isalpha(): new_str = new_str + i a = "abcdefghijklmnopqrstuvwxyz" msg = "Yes, it is a pangram" for i in a: if i not in new_str: msg = "No, it is not a pangram" print(msg)

5: Given a string, create a new string without vowels and print that string

x = ['a', 'e', 'i', 'o', 'u'] y = input("please enter the word: ").lower() result="" print(range(len(y))) for i in range(len(y)): if y[i] not in x: result = result + y[i] else: print(y[i]) print("\nAfter removing vowels: ", result)

Version 2: Using List Comprehension

x = ['a', 'e', 'i', 'o', 'u'] y = input("please enter the word: ").lower() result = [i for i in y if i not in x] print("".join(result))
Tags: Technology,Python,

Friday, April 28, 2023

Ch 4 - Problems on Operator Precedence

Operator Precedence

Problem 1

  • Solve 25 + 10 * 20

Solution 1

  • 25 + 10 * 20 is calculated as 25 + (10 * 20)
  • and not as (25 + 10) * 20
  • >>> 25 + 10 * 20
  • 225

Problem 2

  • What will be output of:
  • print(3*1**3)

Solution 2

  • 3*1**3 is equivalent to: 3 * (1**3)
  • (base) ashish@ashish:~$ python
  • Python 3.9.13 (main, Aug 25 2022, 23:26:10)
  • [GCC 11.2.0] :: Anaconda, Inc. on linux
  • Type "help", "copyright", "credits" or "license" for more information.
  • >>> 3*1**3
  • 3

Problem 3

  • # Precedence of 'or' & 'and'
  • name = "Alex"
  • age = 0
  • if ( name == "Alex" or name == "John" ) and age >= 2 :
  • print("Hello! Welcome.")
  • else :
  • print("Good Bye!!")

Solution 3

Problem 4

  • # Precedence of 'or' & 'and'
  • name = "Alex"
  • age = 0
  • if name == "Alex" or name == "John" and age >= 2 :
  • print("Hello! Welcome.")
  • else :
  • print("Good Bye!!")

Solution 4 (Part 1)

  • Condition: name == "Alex" or name == "John" and age >= 2
  • It is equivalent to:
  • name == "Alex" or (name == "John" and age >= 2)
  • For:
  • name = "Alex"
  • age = 0
  • What will it print(): True or False?

Solution 4 (Part 2)

Operator Associativity

Operator Associativity: If an expression contains two or more operators with the same precedence then Operator Associativity is used to determine. It can either be Left to Right or from Right to Left.

Example: ‘*’ and ‘/’ have the same precedence and their associativity is Left to Right, so the expression “100 / 10 * 10” is treated as “(100 / 10) * 10”.

Problem 5

  • print(100 / 10 * 10)
  • print(5 - 2 + 3)
  • print(2 ** 3 ** 2)

Solution 5

  • # Left-to-right associativity
  • # 100 / 10 * 10 is calculated as
  • # (100 / 10) * 10 and not as 100 / (10 * 10)
  • print(100 / 10 * 10)
  • # Left-to-right associativity
  • # 5 - 2 + 3 is calculated as
  • # (5 - 2) + 3 and not as 5 - (2 + 3)
  • print(5 - 2 + 3)
  • # right-to-left associativity
  • # 2 ** 3 ** 2 is calculated as
  • # 2 ** (3 ** 2) and not as (2 ** 3) ** 2
  • print(2 ** 3 ** 2)
  • >>> 2 ** 3 ** 2
  • 512

Problem 6

  • print(10 + 10 / 10 - 10 * 10)
  • print(100 + 200 / 10 - 3 * 10)

Solution 6

>>> print(10 + 10 / 10 - 10 * 10)

-89.0

Tags: Python,Technology,