Skip to main content

ads1

Class 11th Chapter 3 :- Python Fundamental

 Chapter 3 :- PYTHON FUNDAMENTAL

DEFINE THE TERMS

1. Constant :- A data item that never changes its value during a program run.

2. Identifier :- Name given by user for a part of the program.

3. Keyword :-  Reserved word having special meaning and purpose.

4. Lexical unit :- Other name of taken.

5. Literals :- Constant

6. Token :- The smallest individual unit in a program

7. String literal :- Sequence of characters enclosed in any type of quotes 

8. Variable :- Named stored location whose value can be manipulated during program run.

9. Expression :- Legal combination of symbols and values that together represents a value.

1. What is the difference between a keyword and an identifier ?

SOLUTION :-  

Keyword is a special word that has a special meaning and purpose. Keywords are reserved and are a few. For example, if, elif, else etc. are keywords.

Identifier is a user-defined name given to a part of a program viz. variable, object, function etc. Identifiers are not reserved. These are defined by the user but they can have letters, digits and a symbol underscore. They must begin with either a letter or underscore. For instance, _chk, chess, trial etc. are identifiers in Python.

2.What are literals in Python? How many types of literals are allowed in Python?

SOLUTION :- 

Literals mean constants i.e., the data items that never change their value during a program run. Python allows five types of literals: 

(i) String literals

(ii) Numeric literals 

(iii) Boolean literals 

(iv) Special Literal None

(v) Literal Collections like tuples, lists etc.

3.How many types of strings are supported in Python?

SOLUTION :-

Python allows two string types:

(i) Single-line Strings :- Strings that are terminated in single line 

(ii) Multi-line Strings :- Strings storing multiple lines text.

4. What factors guide the choice of identifiers in programs?

SOLUTION :-

(i) An identifier must start with a letter or underscore followed by any number of digits and/or letters.

(ii) No reserved word or standard identifier should be used. 

(iii) No special character (other than under-score) should be included in the identifier.

5. How can you create multi-line strings in Python? 

SOLUTION :- Multi-line strings can be created in two ways:

(a) By adding a backslash at the end of normal

single-quote or double-quote strings e.g.,

Text =

"Welcome \

Το\

Python"

(b) By typing the text in triple quotation marks. (No backslash needed at the end of line) e.g.,

Str1="""Welcome

Το

Python

"""

6.What is None literal in Python ?

SOLUTION :- 

Python has one special literal called None.

The None literal is used to indicate something that has not yet been created in simple words, or absence of value. It is also used to indicate the end of lists in Python.

7.What is the difference between an expression and a statement in Python ?

SOLUTION :- 



Chapter 3  Python Fundamental











ads2

Popular posts from this blog

11. Write a Java program to input basic salary of an employee and calculate its Gross salary according to following:

    11. Write a Java program to input basic salary of an employee and calculate its Gross salary according to following: Basic Salary <= 10000 : HRA = 20%, DA = 80% Basic Salary <= 20000 : HRA = 25%, DA = 90% Basic Salary > 20000 : HRA = 30%, DA = 95% Static Solution :-  class salary {     public static void main(String args[])     {     double basic=20000.50,gross,da,hra;     if(basic <=10000)     {         da = basic * 0.8;         hra = basic *0.2;     }              else if(basic <=20000)     {         da = basic * 0.9;         hra = basic *0.25;     }     else     {         da = basic * 0.95;         hra = basic * 0.3;     }     gross = basic + da + hra;     System.out.println("The Gross Salary is :-"+gross);     } } Output :-  Dynamic Solution :-  class salary {     public static void main(String args[])     {     double basic=20000.50,gross,da,hra;     Scanner in = new Scanner(System.in);     System.out.println("Enter the Basic Salary

1. Given the school result data, analyses the performance of the students on #different parameters, e.g subject wise or class wise.

1. Given the school result data, analyses the performance of the students on #different parameters, e.g subject wise  or class wise. Solution :-   # x-axis is shows the subject and y -axis # shows the markers in each subject # import pandas and matplotlib  import pandas as pd  import matplotlib.pyplot as plt # Simple Line Chart with setting of Label of X and Y axis, # title for chart line and color of line  subject = ['Physic','Chemistry','Mathematics', 'Biology','Computer'] marks =[80,75,70,78,82] # To draw line in red colour plt.plot(subject,marks,'r',marker ='*')     # To Write Title of the Line Chart plt.title('Marks Scored') # To Put Label At Y Axis plt.xlabel('SUBJECT')           # To Put Label At X Axis plt.ylabel('MARKS')             plt.show() Output :- 

24.Create a Data Frame quarterly sales where each row contains the item category, item name, and expenditure. Group the rows by the category and print the total expenditure per category.

24.Create a Data Frame quarterly sales where each row contains the item category, item name, and expenditure. Group the rows by the category and print the total expenditure per category. import pandas as pd  # initialize list of lists data = [['CAR','Maruti',1000000],['AC','Hitachi',55000],['AIRCOLLER','Bajaj',12000], ['WASHING MACHINE','LG',15000],['CAR','Ford',7000000],['AC','SAMSUNG',45000],['AIRCOLLER','Symphony',20000],['WASHING MACHINE','Wirlpool',25000]] Col=['itemcat','itemname','expenditure'] # Create the pandas DataFrame qrtsales = pd.DataFrame(data,columns=Col) # print dataframe.  print (qrtsales) qs=qrtsales.groupby('itemcat')  print('Result after Filtering Dataframe')  print(qs['itemcat','expenditure'].sum()) Output :-