The math module provides functions for specialized mathematical operations such as ceil, floor, factorial, gcd, exp, log, pow, sqrt, trigonometric functions, and constants such as pi and e. The zlib module provides functions for compressing and decompressing data using the zlib library as well as computing checksums. The threading module allows creating and managing threads in Python. Key concepts include the Thread class for defining new threads, starting and joining threads, and synchronizing thread execution using locks.
Python- Creating Dictionary,
Accessing and Modifying key: value Pairs in Dictionaries
Built-In Functions used on Dictionaries,
Dictionary Methods
Removing items from dictionary
Python- Creating Dictionary,
Accessing and Modifying key: value Pairs in Dictionaries
Built-In Functions used on Dictionaries,
Dictionary Methods
Removing items from dictionary
Learn how to use lists in Java, how to use List<T> and ArrayList<T>, how to process lists of elements.
Watch the video lesson and access the hands-on exercises here: https://softuni.org/code-lessons/java-foundations-certification-lists
Java is a relevant subject area taught in all computer science degree programs. This object-oriented computer language is used to write a variety of Software Applications.
Java Foundations: Maps, Lambda and Stream APISvetlin Nakov
Learn how to work with maps in Java, how to use the Map<K, V> interface and the API classes HashMap<K,V> and TreeMap<K, V>. Learn how to work with lambda expressions and how to use the Java stream API to process sequences of elements, how to filter, transform and order sequences.
Watch the video lesson and access the hands-on exercises here: https://softuni.org/code-lessons/java-foundations-certification-maps-lambda-and-stream-api/
A thread is a separate flow of execution. This means that your program will have two things happening at once. But for most Python 3 implementations the different threads do not actually execute at the same time: they merely appear to.
It’s tempting to think of threading as having two (or more) different processors running on your program, each one doing an independent task at the same time. That’s almost right. The threads may be running on different processors, but they will only be running one at a time.
Getting multiple tasks running simultaneously requires a non-standard implementation of Python, writing some of your code in a different language, or using multiprocessing which comes with some extra overhead.
Learn how to use lists in Java, how to use List<T> and ArrayList<T>, how to process lists of elements.
Watch the video lesson and access the hands-on exercises here: https://softuni.org/code-lessons/java-foundations-certification-lists
Java is a relevant subject area taught in all computer science degree programs. This object-oriented computer language is used to write a variety of Software Applications.
Java Foundations: Maps, Lambda and Stream APISvetlin Nakov
Learn how to work with maps in Java, how to use the Map<K, V> interface and the API classes HashMap<K,V> and TreeMap<K, V>. Learn how to work with lambda expressions and how to use the Java stream API to process sequences of elements, how to filter, transform and order sequences.
Watch the video lesson and access the hands-on exercises here: https://softuni.org/code-lessons/java-foundations-certification-maps-lambda-and-stream-api/
A thread is a separate flow of execution. This means that your program will have two things happening at once. But for most Python 3 implementations the different threads do not actually execute at the same time: they merely appear to.
It’s tempting to think of threading as having two (or more) different processors running on your program, each one doing an independent task at the same time. That’s almost right. The threads may be running on different processors, but they will only be running one at a time.
Getting multiple tasks running simultaneously requires a non-standard implementation of Python, writing some of your code in a different language, or using multiprocessing which comes with some extra overhead.
Using Groovy? Got lots of stuff to do at the same time? Then you need to take a look at GPars (“Jeepers!”), a library providing support for concurrency and parallelism in Groovy. GPars brings powerful concurrency models from other languages to Groovy and makes them easy to use with custom DSLs:
- Actors (Erlang and Scala)
- Dataflow (Io)
- Fork/join (Java)
- Agent (Clojure agents)
In addition to this support, GPars integrates with standard Groovy frameworks like Grails and Griffon.
Background, comparisons to other languages, and motivating examples will be given for the major GPars features.
The JVM memory model describes how threads in the Java eco-system interact through memory. While the memory model impact on developing for the JVM may not be obvious, it is the cause for certain number of "anomalies" that are, well, by design.
In this presentation we will explore the aspects of the memory model, including things like reordering of instructions, volatile members, monitors, atomics and JIT.
This is a single day course, allows the learner to get experience with the basic details of deep learning, first half is building a network using python/numpy only and the second half we build the more advanced netwrok using TensorFlow/Keras.
At the end you will find a list of usefull pointers to continue.
course git: https://gitlab.com/eshlomo/EazyDnn
A review on techniques and modelling methodologies used for checking electrom...nooriasukmaningtyas
The proper function of the integrated circuit (IC) in an inhibiting electromagnetic environment has always been a serious concern throughout the decades of revolution in the world of electronics, from disjunct devices to today’s integrated circuit technology, where billions of transistors are combined on a single chip. The automotive industry and smart vehicles in particular, are confronting design issues such as being prone to electromagnetic interference (EMI). Electronic control devices calculate incorrect outputs because of EMI and sensors give misleading values which can prove fatal in case of automotives. In this paper, the authors have non exhaustively tried to review research work concerned with the investigation of EMI in ICs and prediction of this EMI using various modelling methodologies and measurement setups.
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTjpsjournal1
The rivalry between prominent international actors for dominance over Central Asia's hydrocarbon
reserves and the ancient silk trade route, along with China's diplomatic endeavours in the area, has been
referred to as the "New Great Game." This research centres on the power struggle, considering
geopolitical, geostrategic, and geoeconomic variables. Topics including trade, political hegemony, oil
politics, and conventional and nontraditional security are all explored and explained by the researcher.
Using Mackinder's Heartland, Spykman Rimland, and Hegemonic Stability theories, examines China's role
in Central Asia. This study adheres to the empirical epistemological method and has taken care of
objectivity. This study analyze primary and secondary research documents critically to elaborate role of
china’s geo economic outreach in central Asian countries and its future prospect. China is thriving in trade,
pipeline politics, and winning states, according to this study, thanks to important instruments like the
Shanghai Cooperation Organisation and the Belt and Road Economic Initiative. According to this study,
China is seeing significant success in commerce, pipeline politics, and gaining influence on other
governments. This success may be attributed to the effective utilisation of key tools such as the Shanghai
Cooperation Organisation and the Belt and Road Economic Initiative.
6th International Conference on Machine Learning & Applications (CMLA 2024)ClaraZara1
6th International Conference on Machine Learning & Applications (CMLA 2024) will provide an excellent international forum for sharing knowledge and results in theory, methodology and applications of on Machine Learning & Applications.
ACEP Magazine edition 4th launched on 05.06.2024Rahul
This document provides information about the third edition of the magazine "Sthapatya" published by the Association of Civil Engineers (Practicing) Aurangabad. It includes messages from current and past presidents of ACEP, memories and photos from past ACEP events, information on life time achievement awards given by ACEP, and a technical article on concrete maintenance, repairs and strengthening. The document highlights activities of ACEP and provides a technical educational article for members.
HEAP SORT ILLUSTRATED WITH HEAPIFY, BUILD HEAP FOR DYNAMIC ARRAYS.
Heap sort is a comparison-based sorting technique based on Binary Heap data structure. It is similar to the selection sort where we first find the minimum element and place the minimum element at the beginning. Repeat the same process for the remaining elements.
2. mathmetics
• Provides functions for specialized mathematical
operations.
The following functions are provided by this module:
Number-theoretic and representation functions
Power and logarithmic function
Trigonometric function
Angular conversion
Hyperbolic functions
Special functions
Constants
3. • math.ceil(x)
– Return the ceiling of x, the smallest integer
greater than or equal to x.
• Example:
• >>> math.ceil(12.3)
• 13
4. • math.floor(x)
– Return the floor of x, the largest integer less than
or equal to x.
• >>> math.floor(12.3)
• 12
5. • math.factorial(x)
– Return x factorial.
• >>> math.factorial(5)
• 120
• math.gcd(a, b)
– Return the greatest common divisor of the integers a
and b.
• >>> math.gcd(12,26)
• 2
6. • math.exp(x)
– Return e**x
• >>> math.exp(5)
• 148.4131591025766
• math.log(x, base)
– With one argument, return the natural logarithm of x (to base e).
– With two arguments, return the logarithm of x to the given base.
• >>> math.log(10,10)
• 1.0
• >>> math.log(10,3)
• 2.095903274289385
7. • math.pow(x, y)
– Return x raised to the power y.
• >>> math.pow(2,3)
• 8.0
• math.sqrt(x)
– Return the square root of x.
• >>> math.sqrt(16)
• 4.0
8. • math.cos(x)
– Return the cosine of x radians.
• math.sin(x)
– Return the sine of x radians.
• math.tan(x)
– Return the tangent of x radians.
• math.degrees(x)
– Convert angle x from radians to degrees.
• math.radians(x)
– Convert angle x from degrees to radians
9. • math.pi
– The mathematical constant p = 3.141592..., to
available precision.
• math.e
– The mathematical constant e = 2.718281..., to
available precision.
• math.inf
– A floating-point positive infinity. (For negative
infinity, use -math.inf)
10. assertion
• Assertion is a conditional statement.
• This is used to test an assumption in the program.
• It verifies a conditional statement must be always
TRUE.
• Syntax:
– assert True==fun(x)
– Here assert is keyword, fun() is user defined function, x is
argument
– fun(x) returns a Boolean value which is either True or
False.
– If the returned value is True continues, otherwise Raises an
AssertionError
12. Introduction
• The zlib module provides a lower-level interface
to many of the functions in the zlib compression
library from the GNU project.
• zlib.compress(data, level=-1)
– Compresses the bytes in data, returning a bytes object
containing compressed data.
– level is an integer from 0 to 9 or -1 controlling the
level of compression
– 1 is fastest and produces the least compression, 9 is
slowe
14. • Example:
• a=b'i want to meet you on sunday'
• >>> a
• b'i want to meet you on sunday'
• >>> c=zlib.compress(a,level=2)
• >>> c
• b'x^xcbT(Oxcc+Q(xc9Wxc8MM-
Qxa8xcc/Uxc8xcfS(.xcdKIxacx04x00x90xbfn@'
• p=zlib.decompress(c)
• >>> p
• b'i want to meet you on sunday'
15. • zlib.adler32(data, value)
– Computes an Adler-32 checksum of data. (An Adler-32
checksum is almost as reliable as a CRC32 but can be
computed much more quickly.) The result is an
unsigned 32-bit integer.
– If value is present, it is used as the starting value of
the checksum; otherwise, a default value of 1 is used.
– Passing in value allows computing a running checksum
over the concatenation of several inputs.
– cr=zlib.adler32(a,12)
– >>> cr
– 2448624203
16. • zlib.crc32(data, value)
– Computes a CRC (Cyclic Redundancy Check) checksum
of data.
– The result is an unsigned 32-bit integer.
– If value is present, it is used as the starting value of
the checksum; otherwise, a default value of 0 is used.
– Passing in value allows computing a running checksum
over the concatenation of several inputs.
– cr=zlib.crc32(a,12)
– >>> cr
– 1321257511
18. Introduction
• The program in execution is called “process”
• Executing the number of processes
simultaneously or concurrently is called “multi
processing”
• The light-weight process is called “Thread”
• Executing the number of threads is called
“multi threading”
• A process can be divided into several threads,
each will do a specific task.
19. • Multiple threads within a process share same
address space, and hence share information and
communicate more easily.
• The threads can communicate with each other
which is called “Inter thread communication”
• These are cheaper than processes.
• The Thread has three things:
– It has beginning
– It has an execution sequence
– It has conclusion
20. • A thread can be pre-empted ( interrupted)
• It can be temporarily put on hold, while other
threads are running. This is called “Yielding”.
• To start new thread we call the following
method in Python 2.7*
– thread.start_new_thread(function, arguments)
21. Creating the New thread
• import time
• import thread
• def print_time(threadname,delay): #function definition
• count=0
• while count<5:
• time.sleep(delay)
• count+=1
• print "The thread name is:",threadname,"Delay is:",delay,"n"
• #creating the thread
• try:
• thread.start_new_thread(print_time,("Thread-1",2))
• thread.start_new_thread(print_time,("Thread-2",4))
• except:
• print "There is some error in threading"
22. output
• >>> The thread name is: Thread-1 Delay is: 2
• The thread name is: Thread-2 Delay is: 4
• The thread name is: Thread-1 Delay is: 2
• The thread name is: Thread-1 Delay is: 2
• The thread name is: Thread-2 Delay is: 4
• The thread name is: Thread-1 Delay is: 2
• The thread name is: Thread-1 Delay is: 2
• The thread name is: Thread-2 Delay is: 4
• The thread name is: Thread-2 Delay is: 4
• The thread name is: Thread-2 Delay is: 4
23. The threading module
• The newer threading module included with Python 2.4
provides much more powerful, high-level support for
threads than the thread module discussed in the
previous section.
• The threading module exposes all the methods of the
thread module and provides some additional methods:
– threading.activeCount(): Returns the number of thread
objects that are active.
– threading.currentThread(): Returns the number of thread
objects in the caller's thread control.
– threading.enumerate(): Returns a list of all thread objects
that are currently active.
24. Thread class methods
• In addition to the methods, the threading module has
the Thread class that implements threading. The
methods provided by the Thread class are as follows:
– run(): The run() method is the entry point for a thread.
– start(): The start() method starts a thread by calling the
run method.
– join([time]): The join() waits for threads to terminate.
– isAlive(): The isAlive() method checks whether a thread is
still executing.
– getName(): The getName() method returns the name of a
thread.
– setName(): The setName() method sets the name of a
thread.
25. Creating Thread Using Threading Module
• To implement a new thread using the
threading module, you have to do the
following −
– Define a new subclass of the Thread class.
– Override the __init__(self [,args]) method to add
additional arguments.
– Then, override the run(self [,args]) method to
implement what the thread should do when
started.
26. • import time
• import threading
• #defining class
• class MyThread(threading.Thread):
• def __init__(self,threadID,n,c):
• threading.Thread.__init__(self)
• self.tID=threadID
• self.name=n
• self.counter=c
• def run(self): #entry point to the thread
• for a in range(1,11):
• print("name",self.name,"ID is:",self.tID," :5 * ",a,"=",5*a,"n")
• time.sleep(self.counter) #used to delay
• #creating the threads
• t1=MyThread(1,"Guido Thread",2)
• t2=MyThread(2,"Steev Jobs",4)
• #starting the threads
• t1.start()
• t2.start()
27. To know the information of the current
threads
• print("The name of the First Thread is",t1.getName(),"n")
• print("The Name of the Second Thread is",t2.getName(),"n")
• print("The Name of the Second Thread is",t3.getName(),"n")
• print("The active threads are :",threading.activeCount())
• print("The list of threads is:",threading.enumerate())
28. Output
• The active threads are : 5
• The list of threads is:
[<_MainThread(MainThread, started 2544)>,
<Thread(SockThread, started daemon 3552)>,
<MyThread(Guido Thread, started 2560)>,
<MyThread(Steev Jobs, started 2088)>,
<MyThread(KSR Thread, started 1488)>]
29. Synchronizing Threads
• The threading module provided with Python includes a simple-to-
implement locking mechanism that allows you to synchronize
threads.
• A new lock is created by calling the Lock() method, which returns
the new lock.
• The acquire(blocking) method of the new lock object is used to
force threads to run synchronously. The optional blocking
parameter enables you to control whether the thread waits to
acquire the lock.
• If blocking is set to 0, the thread returns immediately with a 0 value
if the lock cannot be acquired and with a 1 if the lock was acquired.
If blocking is set to 1, the thread blocks and wait for the lock to be
released.
• The release() method of the new lock object is used to release the
lock when it is no longer required.
30. Testing
• Unit Test
– This test is invented by Eric Gamma in 1977
– This test is used to test the individual units or
functions of the program.
– The function may be defined to do some specific
task.
– This functions is tested for all possible value, for
knowing where it is performing its intended task
correctly or not
31. Goals of Unit Test
• There are three goals of unittest
– To make it easy to write tests
– To make it easy to run tests
– To make it easy to tell if the tests are passed
32. How many tests should we have
• Test at least one “typical” case.
• The objective of the testing is not to prove that your
program is working.
• It is to try to find out where it does not test “Extreme” case
you can think.
• For example you want to write test case for “sort()”
function over a list.
• Then some issues you can consider are:
– What if the list contains equal number?
– Do the first element and last element moved to the correct
position?
– Can you sort a 1-element list without getting an error?
– How about an empty list?
33. unittest module
• In Python we have a module called “unittest”
to support unit test.
• to use these tests we create a class that
Inherits the properties from “TestCase” class
of this module.
• Define a method in this class and use the
different methods of the TestCase class.
34. Commonly used methods of TestCase class
assertEqual(a,b)
assertNotEqual(a,b)
assertTrue(x)
assertFalse(x)
assertIs(a,b)
assertIsNone(a,b)
assertIn(a,b)
assertNotIn(a,b)