Advanced Programming Report
Advanced Programming Report
UNIVERSITY OF TECHNOLOGY
ADVANCED PROGRAMMING
Contents
1 The programming language Python 2
Assignment for Advanced Programming - Academic year 2023 - 2024 Page 1/7
University of Technology, Ho Chi Minh City
Faculty of Computer Science
Python’s versatility and powerful libraries make it a popular choice for a wide range of
applications:
1. Web Development: Frameworks like Django and Flask provide robust tools for building
dynamic websites and APIs.
2. Data Science and Machine Learning: Libraries such as Pandas, NumPy, and TensorFlow
enable data analysis, statistical modeling, and predictive analytics.
3. Automation: Python’s simplicity allows for the quick development of scripts to automate
repetitive tasks, making it invaluable for system administrators and developers.
4. Scientific Computing: Libraries like SciPy and Matplotlib support complex mathematical
computations and data visualization.
5. Education: Python is widely used as a primary language for teaching programming and
computer science due to its straightforward syntax and readability.
6. Other Domains:
• Game Development: Python is used for developing games with frameworks like Pygame.
• Network Programming: Python provides tools for creating and managing network
applications.
• Embedded Systems: Python can be used in embedded systems to control hardware.
• Python’s broad utility across these various domains underscores its effectiveness and
widespread adoption in industry, academia, and beyond.
Assignment for Advanced Programming - Academic year 2023 - 2024 Page 2/7
University of Technology, Ho Chi Minh City
Faculty of Computer Science
Brief way:
1 >>> numbers = [1 ,2 ,3 ,4 ,5]
2 >>> [ x for x in numbers if x % 2 == 0]
3 [2 , 4]
4
Assignment for Advanced Programming - Academic year 2023 - 2024 Page 3/7
University of Technology, Ho Chi Minh City
Faculty of Computer Science
2.3 Recursion
Functional programming encourages the use of recursion for iteration rather than traditional
loops. While Python supports recursion, it may not be as optimized for tail recursion as some
other functional languages.
Example: find factorial of a number
1 >>> def factorial ( n ) :
2 ... return 1 if n == 0 else n * factorial ( n - 1)
3 >>> print ( factorial (5) )
4 120
Assignment for Advanced Programming - Academic year 2023 - 2024 Page 4/7
University of Technology, Ho Chi Minh City
Faculty of Computer Science
2. Define functions: Identify the different tasks or operations required to solve the problem
and define functions for each of them. Functions should ideally have a single responsibility
and be reusable.
3. Use pure functions: Aim to write pure functions whenever possible. Pure functions have
no side effects and always return the same output for the same input, making them easier
to reason about and test.
4. Avoid mutable state: Minimize the use of mutable state and global variables, as they
can introduce complexity and make your code harder to understand and debug.
5. Leverage higher-order functions: Python supports higher-order functions, which are
functions that can accept other functions as arguments or return functions as results.
Leverage these to create more flexible and reusable code.
6. Use functional programming tools: Python provides several tools and libraries for
functional programming, such as map(), filter(), and reduce(). These tools allow you to
perform common functional programming operations like mapping, filtering, and reducing
sequences.
Assignment for Advanced Programming - Academic year 2023 - 2024 Page 5/7
University of Technology, Ho Chi Minh City
Faculty of Computer Science
Assignment for Advanced Programming - Academic year 2023 - 2024 Page 6/7
University of Technology, Ho Chi Minh City
Faculty of Computer Science
1 Welcome to Hangman !
2 ___________
3 Guess a letter : a
4 Correct !
5 _____a_____
6 Guess a letter : i
7 Correct !
8 _____a__i__
9 Guess a letter : e
10 Incorrect ! You have 5 attempts left .
11 _____a__i__
12 Guess a letter : o
13 Correct !
14 __o__a__i__
15 Guess a letter : p
16 Correct !
17 p_o__a__i__
18 Guess a letter : r
19 Correct !
20 pro_ra__i__
21 Guess a letter : g
22 Correct !
23 progra__i_g
24 Guess a letter : m
25 Correct !
26 programmi_g
27 Guess a letter : m
28 You ' ve already guessed that letter !
29 programmi_g
30 Guess a letter : n
31 Correct !
32 programming
33 C on gr a tu la t io n s ! You guessed the word : programming
Assignment for Advanced Programming - Academic year 2023 - 2024 Page 7/7