0% found this document useful (0 votes)
4 views10 pages

Python Pack

The document provides an overview of Python programming, highlighting its characteristics, similarities and differences with Java, areas of application, disadvantages, and practical exercises. It emphasizes Python's object-oriented nature, ease of use, and versatility in various domains such as web development, machine learning, and game development. Additionally, it outlines practical programming tasks and answers to objective questions related to Python.

Uploaded by

Chizoba Onyeyi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views10 pages

Python Pack

The document provides an overview of Python programming, highlighting its characteristics, similarities and differences with Java, areas of application, disadvantages, and practical exercises. It emphasizes Python's object-oriented nature, ease of use, and versatility in various domains such as web development, machine learning, and game development. Additionally, it outlines practical programming tasks and answers to objective questions related to Python.

Uploaded by

Chizoba Onyeyi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

1. What is Python Programming?

Ans: Python is an interpreted object-oriented, high – level programming language with dynamic
semantics. Its high-level built in data structures, combined with dynamic typing and dynamic binding,
make it very attractive for Rapid Application Development, as well as for use as a scripting or glue
language to connect existing components together. Python’s simple, easy to learn syntax emphasizes
readability and therefore reduces the cost of program maintenance. Python supports modules and
packages, which encourages program modularity and code reuse.

2. Explain 7 similarities between Java and Python?

Ans:

a. They are Object – Oriented Programming:

This means that they are programming paradigm that relies on the concept of classes and objects which
are used to structure a software program into simple, reusable pieces of code blueprints (usually called
classes), creating individual instances of objects.

b. They are high – level languages:

This means that the languages are very close to human language, hence easy to understand and
comprehend.

c. They both support cross – platform/multi – platform:

This means that the software programmed in both languages can run on different type of processor or
compatible with other hardware, which software or VM.

d. They have third – party modules to extend their functionalities:

This third – party modules can help impact how quickly a novice programmer is able to pick these
languages.

e. They compile to byte code and run in virtual machines:

This isolates codes form differences between operating system making the languages cross – platform,
but it is essential to know that while python usually compiles code at runtime while java compiles it in
advance, and distributes the byte code.

f. They can be used for Web Development:

Python is almost exclusively used for backend, server-facing work, this is made possible via the popular
python framework Django, Pyjs also allows developers to write front end applications in python which is
then compiled into JavaScript. While Java’s use in building web application is mostly confined to
backend, server – facing work.

g. They are general – purpose languages

3. Explain 7 differences between Java and Python?

Ans:
a. Code Readability:

Java code is very verbose compared to python, for example when you want to write a simple operation
in java like printing “Hello, World”, it will take 5 – 6 lines of code while Python programs are relatively
smaller as you can achieve the same thing in python using one print statement.

b. Database:

Java has strong database connectivity through JDBC and is widely used while Python database
connectivity is rather weak and not much used in actual enterprise applications.

c. Object Model:

Everything in Java starts and ends with object, an example is a program to print “Hello” requires you to
write a class while in Python there are objects but we can also write programs without objects and
classes.

d. Easy – to – use:

Java has larger code and is also statically typed, and is not that easy to use while Python is dynamically
typed and smaller code, hence it is easy to use.

e. Syntax:

Java syntax is rather strict, if you miss semicolon at the end or mismatch curly braces, you get errors
while Python has easier syntax, only the indentation matters, and there is no compulsion for semicolon
or curly braces.

f. Typing:

Java is statically typed object-oriented concurrent programming language while Python is dynamically
typed object-oriented programming language.

g. Performance:

Java has better performance than Python in terms of speed and efficiency. With the help of Just – in –
Time (JIT) compiler, efficiency of java programs is improved considerably. Also, parallel programming
improves the speed thus enhancing the performance as a whole while Python, contrary to compiling the
entire program, each program statement is taken at a time for interpretation slowing the program. Type
checking is also done at run time and identifying the objects from collection takes up lot of memory thus
reducing the performance.

4. Explain 7 areas of application of Python Language

Ans:

a. Game Development:

Python is also used in the development of interactive games. There are libraries such as PySoy which is a
3D game engine supporting Python 3. PyGame which provides functionality and a library for game
development. Examples are Disney’s Toontown Online, Civilization – IV.
b. Machine Learning and Artificial Intelligence:

Making computer learn based on past experiences through the data stored or better yet, create
algorithms which makes the computer learn by itself, Python has libraries for these domains such as
Pandas, Scikit-Learn, NumPy, TensorFlow and so many more.

c. Data Science and Data Visualization:

Data can be extracted using libraries such as Pandas, NumPy. Visualizing data libraries is possible using
Matplotlib, Seaborn which are helpful in plotting graphs and much more, hence helping an individual in
launching his/her career to become a Data Scientist.

d. Web Development:

Python can be used to make web – applications at a rapid rate as it has a common – backend logic that
goes into making its frameworks and a number of libraries that can help integrate protocols such as
HTTPS, FTPS, SSL etc. even help in processing of JSON, XML, E – mail and so much more. Some of the
most well – known frameworks are Django, Flask, Pyramid and the security, scalability and convenience
provided is commendable when compared to starting the development of a website from scratch.

e. CAD Applications:

Computer – Aided Designing is quite challenging to make as many things have to be taken care of.
Objects and their representation, functions are just the tip of the iceberg when it comes to something
like this. Python makes this simple too and the best – known application for CAD is Fandango.

f. Web Scraping Applications:

Python is a savior when it comes to pull a large amount of data from websites which can then be helpful
in various real – world processes such as price comparison, job listings, research and development and
much more.

g. Embedded Applications:

Python is based on C which means that it can be used to create Embedded C software for embedded
applications. This helps us to perform higher – level applications on smaller devices which can compute
python.

1. State 5 disadvantages of Python

Ans:

a. Runtime Errors: One of the major drawbacks of this language is that its design has numerous issues.
Python programmers face several issues regarding the design of the language. This language requires
more testing and also it has errors that only show up at runtime this is because the language is
dynamically typed.

b. Database Access: Python is a robust programming language with minimal stress and worries. But, this
language is highly insecured and can be used only at one’s own risk. There are some limitations of
Python with database access. In comparison to the popular technologies like JDBC and ODBC, it is found
that Python’s database access layer is a bit underdeveloped and primitive. It acts as a major barrier
when big enterprises look for a language that ensures smooth interaction of complex legacy data.
However, the enterprises that need smooth interaction of complex legacy data, the Python database
access layer is not applied. That is, it is less often applied in huge enterprises.

c. Memory Consumption: For any memory intensive tasks Python is not a good choice. That is why it is
not used for that purpose. Python’s memory consumption is also high, due to the flexibility of the data
types.

d. Mobile Development: Python is strong in desktop and server platforms that is it is an excellent
server-side language but for mobile development, Python is not a very good language which means it is
a weak language for mobile development. It is very rarely used for mobile development. This is the
reason very few mobile applications are built in it like Carbonnelle, which is built-in python.

e. Gets Slow in Speed: Python executes with the help of an interpreter instead of the compiler, which
causes it to slow down because compilation and execution help it to work normally. On the other hand,
it can be seen that it is fast for many web applications too.

2. List Python Reserved / Keywords

List: this is a heterogeneous container for items. It is used to store data of different data type in python
and enclose with angular bracket [ ]. Example: li =[2,5,q,cat,t]. it is mutable unlike the tuple datatype
that cannot be altered.

Tuple: this is like the list but the only difference is that it cannot be altered or change. It stores items of
different data type enclosed with a pair of parenthesis. Eg P1 = (1,3,4,9,9)

Dictionary is the type of data type that stores the key and value of items enclosed with the pair curly
braces. Eg {a:3, b:89, sum:29}

Set: this is just the like the mathematical set. It contains items of the same datatype and usually mutable
or changeable. It is unordered in nature. Eg. Y3 = {1,4,6} etc.

PYTHON PROGRAMMING LANGUAGE PRACTICAL


Practical 1.

Title: Using Print and Input function

Write Python Programme that welcomes you with your name and print

It’s interesting learning python language.


Practical 2

Title: Average of numbers

Write Python Programme that displays the sum of three (3) numbers

Practical 3

Write a program that ask a user to input five numbers, the program should compute and output the sum and average of
the numbers

NB: The output must be interactively clear


Practical 4

A school uses the following graduation criteria:

GPA AWARD

2.00-2.49 PASS

2.50–2.99 LOWER CREDIT

300–3.49 UPPER CREDIT

3.50–4.00 DISTINCTION
Practical 5

Write a python program to print all prime numbers between 1 and 1000

Practical 6

Write a python program to generate the first 100 Fibonacci numbers without using function
Practical 7

Write a python program to generate the first 100 Fibonacci numbers without using Recursive function

Practical 8

Write python class program for triangle with three sides a, b, c. The program should ask for input of the size, display the
sides, area and perimeter
Practical 9

Write the program in practical 1 above without class


ANSWERS TO OBJECTIVE QUESTIONS

1. C
2. D
3. TRUE
4. C
5. Lower cases except True and False
6. A
7. A
8. B
9. B
10. D
11. C
12. C
13. A
14. D
15. A
16. C
17. B
18. D
19. C
20. B
21. B
22. C
23. B
24. D
25. C
26. D
27. B
28. C
29. D
30. C

You might also like