Posted in Home

Control Flow

Python if else

There comes situations in real life when we need to make some decisions and based on these decisions, we decide what should we do next. Similar situations arises in programming also where we need to make some decisions and based on these decisions we will execute the next block of code.

Decision making statements in programming languages decides the direction of flow of program execution. Decision making statements available in python are:

  • if statement
  • if..else statements
  • nested if statements
  • if-elif ladder
  • Short Hand if statement
  • Short Hand if-else statement

if statement

if statement is the most simple decision making statement. It is used to decide whether a certain statement or block of statements will be executed or not i.e if a certain condition is true then a block of statement is executed otherwise not.

Here, condition after evaluation will be either true or false. if statement accepts boolean values – if the value is true then it will execute the block of statements below it otherwise not. We can use condition with bracket ‘(‘ ‘)’ also.

As we know, python uses indentation to identify a block. So the block under an if statement will be identified as shown in the below example:

if condition:               # Statements to execute if    # condition is true
if-statement-in-java

if- else

The if statement alone tells us that if a condition is true it will execute a block of statements and if the condition is false it won’t. But what if we want to do something else if the condition is false. Here comes the else statement. We can use the else statement with if statement to execute a block of code when the condition is false.
Syntax:

if (condition):
    # Executes this block if
    # condition is true
else:
    # Executes this block if
    # condition is false

Flow Chart:-

Posted in Home

Data Types

Python | Set 3 (Strings, Lists, Tuples, Iterations)

Last Updated: 20-10-2020

In the previous article, we read about the basics of Python. Now, we continue with some more python concepts.

Strings in Python 
A string is a sequence of characters. It can be declared in python by using double-quotes. Strings are immutable, i.e., they cannot be changed.

Assigning string to a variable
 a = "This is a string"
 print (a) 

Lists in Python 
Lists are one of the most powerful tools in python. They are just like the arrays declared in other languages. But the most powerful thing is that list need not be always homogeneous. A single list can contain strings, integers, as well as objects. Lists can also be used for implementing stacks and queues. Lists are mutable, i.e., they can be altered once declared.

# Declaring a list 
L = [1, "a" , "string" , 1+2] 
print L 
L.append(6) 
print L 
L.pop() 
print L 
print L[1] 

The output is :  

[1, 'a', 'string', 3]
[1, 'a', 'string', 3, 6]
[1, 'a', 'string', 3]
a


Tuples in Python 
A tuple is a sequence of immutable Python objects. Tuples are just like lists with the exception that tuples cannot be changed once declared. Tuples are usually faster than lists.

Example

Create a Tuple:

thistuple = ("apple", "banana", "cherry")
print(thistuple)
Posted in C++/Python

Operators

  1. Arithmetic operators: Arithmetic operators are used to perform mathematical operations like addition, subtraction, multiplication and division.
OPERATORDESCRIPTIONSYNTAX
+Addition: adds two operandsx + y
Subtraction: subtracts two operandsx – y
*Multiplication: multiplies two operandsx * y
/Division (float): divides the first operand by the secondx / y
//Division (floor): divides the first operand by the secondx // y
%Modulus: returns the remainder when first operand is divided by the secondx % y
**Power : Returns first raised to power secondx ** y

Example:

for example, open any of your text editor(notepad/notepad++), then copy the code below

a = 9
b = 4
#Addition of numbers
add = a + b 
#Subtraction of numbers
sub = a - b 
#Multiplication of number
mul = a * b 
#Division(float) of number
div1 = a / b 
#Division(floor) of number
div2 = a // b 
#Modulo of both number
mod = a % b 
#Power
p = a ** b 
print results
print(add) 
print(sub) 
print(mul) 
print(div1) 
print(div2) 
print(mod) 
print(p) 

Save this file with test.py, then search your Command Prompt (.cmd) in your windows, open it, then type: python test.py, or python3 test.py.

Output:

13 5 36 2.25 2 1 6561
Posted in Home

Input/Output

Developers often have a need to interact with users, either to get data or to provide some sort of result. Most programs today use a dialog box as a way of asking the user to provide some type of input. While Python provides us with two inbuilt functions to read the input from the keyboard.

  • input ( type your input here)
  • raw_input ( type your input here )

input ( ) : This function first takes the input from the user and then evaluates the expression, which means Python automatically identifies whether user entered a string or a number or list. If the input provided is not correct then either syntax error or exception is raised by python. For example:

  • Các nhà phát triển thường có nhu cầu tương tác với người dùng, để lấy dữ liệu hoặc cung cấp một số loại kết quả. Hầu hết các chương trình ngày nay đều sử dụng hộp thoại như một cách để yêu cầu người dùng cung cấp một số kiểu đầu vào.
  • Trong khi Python cung cấp cho chúng ta hai hàm có sẵn để đọc đầu vào từ bàn phím.
    • input (lời nhắc)
    • raw_input (lời nhắc) input ():
  • Hàm này trước tiên lấy đầu vào từ người dùng và sau đó đánh giá biểu thức, có nghĩa là Python tự động xác định xem người dùng đã nhập một chuỗi hay một số hoặc danh sách. Nếu đầu vào được cung cấp không chính xác thì một trong hai lỗi cú pháp hoặc ngoại lệ được đưa ra bởi python. Ví dụ :
Python program showing
 a use of input()
 val = input("Enter your value: ") 
 print(val) 
Posted in Home, Life in Europe

Work-life balance of Software Engineer in Germany

The issues around finding the balance between family life, private life and work are gaining increased attention in political and business circles in Europe and Germany.

A key issue for many workers is flexible working time in order to have a work-life balance. Negotiating a work/life balance can help enable parents (both men and women) to reconcile their work with their family lives and women in particular to participate in the labour market. Finding the right work-life balance can allow workers to take leave from work so that they can participate in education or training or take up an interest, hobby or leisure pursuit. This may mean that employees can reorganise their working lives and hours around shorter days, weeks, months or years.

German families tend to be small with only one or two children. The men are still quite often considered to be the head of the household, even though both the wife and husband work.

At the turn of the century few employees in Germany were given holidays. In 1902, the metal and brewing industries gave three days annual leave to their workers. It was not until 1974 that the old Federal Republic introduced the statutory minimum holiday of 18 working days which has now risen to a minimum of 24 days. Today most collective wage agreements provide for holidays of six weeks or more and most employers give  holiday pay.

National holidays

Germany has quite generous holidays in comparison to other European countries. There are more public holidays in Germany than in any other European country. On these days, banks and most shops are closed, including supermarkets. However, many restaurants remain open. Public transportation and other services are also available. Many shops and businesses are also closed on Carnival Rose Monday (Cologne and Rhine region), Christmas Eve and New Year’s Eve although these are not official holidays.

Overview of legal holidays:

New Year                
Epiphany                   
Good Friday              
Easter Monday               
Labour Day               
Ascension                  
Whit Monday             
Corpus Christi                       
Assumption Day        
Day of German Unity            
Reformation Day       
All Saints’ Day                       
Penance Day              
Christmas                  
St. Stephen’s Day
01.01
06.01   (celebrated in BW, BY, ST)
around March/April
around March/April
01.05
May
May
May/June (celebrated in  BW, BY, HE, NW, RP, SL)
15.08   (celebrated in  BY, SL)
03.10
31.10   (celebrated in  BB, MV, SN, ST, TH)
01.11   (celebrated in BW, BY, NW, RP, SL
21.11   (celebrated in SN)
25.12
26.12

(Those States where the public holiday applies are shown in brackets; if nothing is indicated the holiday applies to all of Germany.)

Working hours

Opening hours

In Germany, businesses and shops are not legally allowed to stay open as long as they please and there are strict regulations concerning opening and closing hours. The German federal law “Ladenschlussgesetz” (Shop Closing Law) together with individual regulations in different States controls opening hours. Thus supermarkets for example close at 22.00 at the latest and open before 9 a.m. or 10 a.m. On Sundays almost everything is closed with the exception of bakeries and petrol stations.

 Working times

The German Working Time Regulations (“Arbeitszeitgesetz”) regulate working hours on a legal basis. They are based on the European regulation 93/104/EG. In addition, most industries have collective agreements that regulate working hours and holidays. However, it can be said, that a working week of more than 48 hours on average during a  6 month period must not be exceeded. Furthermore, Sundays and national holidays are non-working days.

Working culture

Germans see themselves as modern, liberal and cultured, and working practices are formal and professional. The following outlines the working practices that you should be familiar with before investing in Germany:

  • Though long-term relationships are considered very important, friendships are usually not developed too quickly. It may take some time before personal names are used between non-familial parties.
  • German business culture has a well-defined and strictly observed hierarchy, with clear responsibilities and distinctions between roles and departments.
  • Professional rank and status in Germany is generally based on an individual’s achievement and expertise in a given field. Academic titles and backgrounds are important, conveying an individual’s expertise and thorough knowledge of their particular area of work.
  • An important aspect is Germany’s work ethic. Employees define themselves as part of the corporation they are working for and quickly identify themselves with its product and/ or services.
  • Rank is very important in business. Never set up a meeting for a lower ranked company employee to meet with a higher ranked person.
  • Notwithstanding what has been said previously, today over half of all university graduates are women. Female students are well represented in the professions; they lead in some fields such as medicine and law. The new availability of qualified female graduates is likely to bring great changes in the German workplace of the future.
  • Pay and power inequalities are still present however. Male employees tend to receive higher wages than their female counterparts. Jobs considered as being “women’s work” typically pay less than those deemed “men’s work”.
  • In more traditional companies, it is still generally true that everything is run by committees, things are discussed in great length and risk taking is not as common as in other countries.
  • There is one philosophy for almost everybody in German business: if someone says he is going to do something, he will do it. The same is expected of others as well. Never make a promise that you cannot keep or offer something that you cannot deliver. Germans dislike and do not trust unreliable people.
  • There is no legislated or administratively determined minimum wage. Collective bargaining agreements set minimum pay rates and are enforceable by law for an estimated 80 to 90 per cent of all wage and salary earners
  • Federal regulations limit the working week to a maximum of 48 hours, but collective bargaining agreements may supersede these. Contracts that directly or indirectly affect 80% of the working population regulate the number of hours of work per week.
  • The average working week is around 40 hours; rest periods for lunch are accepted practice. Provisions for overtime, holidays, and weekend pay vary depending upon the applicable collective bargaining agreement.
  • An extensive set of laws and regulations govern occupational health and safety. A comprehensive system of worker insurance enforces safety requirements in the workplace.

It is important that these issues are examined and understood before setting up a company and employing a workforce in Germany. These issues differ all over Europe but legal guidelines are set by the European Commission.

Health insurance

Germany’s health care system provides its residents with nearly universal access to comprehensive high-quality medical care and a choice of physicians. Over 90% of the population receives health care through the country’s statutory health care insurance programme. Membership of this programme is compulsory for all those earning less than a periodically revised income ceiling. Nearly all of the remainder of the population receives health care via private for-profit insurance companies. Everyone uses the same health care facilities.

Posted in Live*

US Election 2020 – What Asian American Think.[Live 11.06.2020]

Combination picture of Democratic U.S. presidential nominee Joe Biden and US President Donald Trump speaking about the early results of the 2020 election on 4 November 2020
image captionThe result of Tuesday’s election hangs in the balance

The information I show in this post only represent for my idea. A Vietnamese engineer in Europe.

Before we discuss further, let’s update some information about the Election in American first:

Democratic candidate Joe Biden has pulled ahead of Donald Trump in Pennsylvania, a key state in the US presidential race, voting data shows.

If Mr Biden takes the state, he would secure his victory in the election. The state has 20 Electoral College votes.

According to the most recent data, Mr Biden is leading by more than 5,500 votes, with 98% counted.

Earlier, Mr Biden edged ahead of his Republican rival in Georgia, another key battleground state.

He is leading there with more than 1,000 votes, with 99% of the ballots counted.

No news organisation has yet projected it as a Biden win. Georgia is a traditionally Republican state and has not been won by a Democrat since 1992.

If Mr Biden wins Pennsylvania, the state where he was born, he would have 273 votes in the electoral college – enough to clinch the victory.

Pennsylvania has always been a major political battleground. The state voted Democrat in six consecutive races before it swung to Mr Trump in 2016.

Paths to victory

How about Asian-American, what they think and who they want to be the 46th president of US. And this is what I found from internet.

Indian-Americans voted for Biden, Vietnamese-Americans supported Trump.

According to post-voting polls, about 64% of Asian American voters support Biden, while 30% of them vote for Trump.

These figures are similar to 2016, but lower than the numbers Obama collected in 2012.

Asian Americans were the fastest growing minority of voters eligible to vote. Although this group’s voter rate is still less than 5%, it may still be the deciding factor in fluctuating states.

According to the Asian-American Voter Survey, the Republican Party has gradually received support from this group in recent years, but nearly two-fifths of Asian-American voters have yet to register as a member of either two parties, meaning they may be “undecided voters”.

Asian-American voters are far from other blocs. They come from many different backgrounds, including country of origin, culture, religion and generation. According to the survey above, Indian Americans tend to vote for Biden the most, while Vietnamese Americans tend to favor Trump.

Although President Trump has been widely criticized for calling Covid-19 “the Chinese virus”, he has received enthusiastic support from a number of Chinese Americans.

Chenren Shao, a 35-year-old Chinese-American Republican voter in Maryland, said he was not offended by the term, as the virus started to emerge from China.

In addition, similar to the Cuban Americans who supported Trump, many Chinese immigrants who criticized Beijing have also praised Trump for claiming he stood up against communism.

Historically, both of these major parties have not had adequate access to Asian-American voters, resulting in a low turnout rate in this group. But in the near future, this electoral block will become large so that politicians must pay more attention.

Posted in Life in Europe

Living in Europe

In this post I will tell you about life of a Asian Developer in Europe. It actually really hard but some time it is, like in the below picture , when you see the guy grow up in home town with sea and temperature always higher than 25, now he need to go home under the weather -5 degree.

This is my bicycle, in Germany where I live, you don’t need a bicycle because you can rent one.

This is the first car I was drive to in Germany, to get a driving license here you need from 2000 to 3000 euros. But It’s still small compare to the money you need to spent every month to your car, have a car in Germany is expensive.