Python

yu yang
yu yang
Sep 5, 2018 · 4 min read

Journey with Udacity Data Science Challenge Scholarship 2018/2019 powered by Bertelsmann — — Blog 5

What is the most important things in Python?

  1. Case sensitive
  2. Spacing is important in Python

What are the basic operators in Python?

What do you need to know about variables in Python?

  1. Only use ordinary letters, numbers or underscores in your variable names.
  2. Variable names can not have spaces.
  3. Variable names need to start with a letter or underscore.
  4. 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.

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

Which build-in objects that are considered False in Python?

  1. Constants defined to be false: None and False
  2. Zero of any numeric type: 0, 0.0, 0j, Decimal(0), Fraction(0,1)
  3. 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 * y

With this structure, lambda expressions aren’t ideal for complex functions, but can be very useful for short, simple functions.




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.

Source: likegif.com
yu yang

Written by

yu yang

On my way to be optimistic and data Scientist

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade