Skip to content

wdi-atx-11/python_challenges

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

General Assembly Logo

Learning Python

You've learned Ruby, C, C++, JavaScript and SQL. Getting started with a totally new language doesn't have to be hard. The biggest key is to practice doing something that you already know in the context of the new language. This is called a transfer task. The more languages and computer science concepts you learn, the easier new ones become to pick up and its mostly syntax, quirks and language-specific tools that become the tricky part.

Now, your task is to teach yourself a bit of Python. The goal here isn't to become a Python master, but to explore and learn a bit about a new language.

All exercises below should be done with Python 3

Goals:

By the end of this exercise, you should be able to:

  • Create a simple python program
  • Execute a simple python program
  • Articulate basic differences between Python and other languages you know
  • Feel comfortable understanding what is generally happening in most basic python programs

Installing Python

Your Mac comes with Python 2.7. We want Python 3.

brew install python3

Execute the Python REPL with:

python3

Execute a Python program with:

python3 program.py

Research: What is Python

Your first task is to research Python to be able to understand some of its basic concepts. Edit this README.md file to answer the below questions:

What paradigms does Python support?
What typing discipline does it follow?
Is it a high or low level language?
Does it have built in memory management and garbage collection?
What languages was Python influenced by?
Is it a compiled or interpeted language?
Does it have strong support for functional programming?
What's the deal with Python 2 vs Python 3?
How do you open a REPL for Python?
How does one execute a Python program?

Read: The Zen of Python

The Zen of Python, by Tim Peters

Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess. There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless you're Dutch. Now is better than never. Although never is often better than right now. If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- let's do more of those!

Hello World

Write a program in hello_world/hello_world.py that prints 'Hello, World!' to the standard output (terminal).

Fizzbuzz

Write a program in fizzbuzz/fizzbuzz.py that does the following:

For numbers 1 through 100, print fizz if the number is divisible by 3, buzz if the number is divisible by 5 and fizzbuzz if the number if the number is divisible by both 3 and 5. If the number isn't divisible by 3 or 5, just output the number itself.

The output should look something like 1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 Fizz Buzz 16 17 Fizz...

Fibonacci

Write a program in fibonacci/fib.py that will output the N-th term of the Fibonacci sequence.

For example: print fib(6) should output 8.

Project Euler Problem 1

Project Euler's first problem is:

If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000.

Write the code to complete this in euler_1/sum_of_natural_numbers.py

Conclusion

How does Python compare to other langauges you've used? Which language is is closest to?

About

A self directed introduction to Python 3

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%