Python
Journey with Udacity Data Science Challenge Scholarship 2018/2019 powered by Bertelsmann — — Blog 5
What is the most important things in Python?
- Case sensitive
- Spacing is important in Python
What are the basic operators in Python?
What do you need to know about variables in Python?
- Only use ordinary letters, numbers or underscores in your variable names.
- Variable names can not have spaces.
- Variable names need to start with a letter or underscore.
- You can’t use reserved words or built-in identifiers that have important purposes in Python.
What are the errors and exceptions in Python?
What is method?
Method is related to functions but unlike functions methods are associated with specific types of objects. That is, there are different methods depending on the types of data you are working with.
Example: String method — format()
maria_string = "Maria loves {} and {}"
print(maria_string.format("math","statistics"))animal = "dog"
action = "bite"
print("Does your {} {}?".format(animal, action))
What is mutability and order?
Mutability is about whether or not we can change an object once it has been created.
Mutable: List, Set, Dictionary
Dictionaries can have keys of any immutable type, like integers or tuples, not just strings.
Immutable: String, Tuple
Tuples can also be used to assign multiple variables in a compact way.
dimensions = 52, 40, 100
length, width, height = dimensions
print("The dimensions are {} x {} x {}".format(length, width, height))Order is about whether the position of an element in the object can be used to access the element.
Order: String, List, Tuple
Unordered: Set
One application of a set is to quickly remove duplicates from a list
numbers = [1, 2, 6, 3, 1, 1, 6]
unique_nums = set(numbers)
print(unique_nums)Which build-in objects that are considered False in Python?
- Constants defined to be false:
NoneandFalse - Zero of any numeric type:
0,0.0,0j,Decimal(0),Fraction(0,1) - Empty sequences and collections:
'"",(),[],{},set(),range(0)
How to create a list really quickly and concisely in Python?
With List Comprehensions
capitalized_cities = [city.title() for city in cities]squares = [x**2 for x in range(9) if x % 2 == 0]
What is the variable scope?
Variable scope refers to which parts of a program a variable can be referenced, or used, from. If a variable is created inside a function, it can only be used within that function(local variable). Accessing it outside that function is not possible. Variables defined outside functions, can still be accessed within a function. However, the value of a global variable can not be modified inside the function.
What is lambda expressions?
You can use lambda expressions to create anonymous functions.
multiply = lambda x, y: x * yWith this structure, lambda expressions aren’t ideal for complex functions, but can be very useful for short, simple functions.
Hier are some useful links for Scripting Python in Windows.
Hier are some useful links for Learning Python.
There is actually an awesome alternative to the default python interactive interpreter, IPython, which comes with many additional features.
I am now 93% new to data science. Any advises to my blog are welcome! Feel free to contact me if you have any problem or doubts about the content. You can also find me hier LinkedIn.

