Python Classroom notes 25/Aug/2024

Process and Need for IPC

  • Two applications running on same machine in different processes cannot access each other’s data (its store in private memory)
  • To enable this communication, we have IPC technologies
    • Named Pipes (Windows)
    • Unix Sockets
    • File
  • Next steps:
    • Need for communication between applications on different machines was introduced
      • RPC
      • Web Sites (http)
      • Web API
        • REST API
      • Web Sockets
      • GraphQL
      • gRPC

Find all the factors of the number (apart from 1 and itself)

  • Samples
15 => 3,5
60 => 2,3,4,5,6,10,12,15,20,30
  • Instructions
1. Hello Flora
2. number = 15
3. index = 2
4. remainder = number%index
5. if remainder == 0, say index
6. index = index + 1
7. if index < number
    7.1 go to line no 4
8. bye

Find if the number is prime or not

  • Samples
7 => prime number
9 => not a prime number
  • Instructions
1. Hello Flora
2. number = 7
3. index = 2
4. remainder = number % index
5. if remainder == 0 
    5.1 say not prime
    5.2 go to line no 9
6. index = index + 1
7. if index < number
    7.1 Go to line number 4
8. say prime
9. bye

Project euler 1:

1. Hello flora
2. result = 0
3. index = 2
4. max = 10
5. is_divisible = (index%3 == 0) or (index%5==0)
6. if is_divisible == True
    6.1 result = result + index
7. index = index + 1
8. if index < max
    8.1 Go to line 5
9. say result

System Setup – Windows

  • Ensure Git is installed and view is added to Terminal
  • Ensure Chocolatey is installed (Window 10 or above)
  • Install python using chocolatey choco install python --version=3.12.5 -y
  • Enable Autosave
  • Now launch visual studio code an install
    • python extension
    • jupyter extension
  • Window cheatshet for vs code Refer Here

System Setup – Mac

  • Ensure homebrew is installed Refer Here
  • Install
    • git: brew install git
    • visual studio code: brew install --cask visual-studio-code
    • python brew install python@3.12
  • Now launch visual studio code an install
    • python extension
    • jupyter extension
  • Visual studio code mac cheatsheet Refer Here

Lets understand debugging

  • Sample code for debugging
result = 0
index = 2
max = 10
while index < max:
    if (index%3 == 0) or (index%5==0):
        result = result + index
    index = index + 1
print(f"sum = {result}")

Accounts Needed

  • Github
  • HackerRank
Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a comment

Turn on JavaScript to leave a comment.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Social Media Icons Powered by Acurax Web Design Company
Exit mobile version
%%footer%%