Python classroom notes 17/April/2024

Problems

Problem 1

  • Make ishika say all the numbers from 1 to 10
hi ishika
say 1
say 2
say 3
say 4
say 5
say 6
say 7
say 8
say 9
say 10
  • other way (looping constructs)
Hi ishika
remember 1 as start  (start = 1)
remember 10 as end   (end = 10)
until start <= end
    say start
    calculate start + 1 and assign it to start (start = start + 1)
end

problem 3

  • Make ishika say numbers from 1 to 100, but when the number is divisible by 3 make her say buzz and when the number is divisible by 5 make her say bam
1
2
buzz
4
bam
buzz
7
8
buzz
bam
  • To print numbers
Hi ishika
start = 1
end = 100
until start <= end
    if start%3 == 0 and start%5 ==0
        say buzzbam
    else start%3 == 0
       say buzz
    else if start%5 == 0
       say bam
    else 
        say start
    start = start + 1
end
  • output
1
2
buzz
4
bam
..
..
buzzbam

Project euler problem 1

Hi ishika
start = 1
end = 10
sum = 0
until start < end
    if start%3 == 0 or start %5 == 0
      sum = sum + start
    start = start + 1
end

Variables

  • In programming, we need to store values and we create variables or constants for that
  • Generally variables are stored in RAM
  • We need to specify some sizes or units, so programming languages provide Datatypes for programmers convinience.
  • The Datatypes are classified into following for convinience
    • Scalar Refer Here
      • integers
      • decimals
      • character
      • boolean
    • Complex
      • array or list
      • structure
      • classes objects
  • Datatypes for compiler
    • fixed size (mutable datatypes)
    • variable size (immutable datatypes)

Project Idea

  • Interview Questions Service

Problem: Find factors of a number

  • Sample
10 = 2,5
28 = 2,4,7,14
  • Solution
Hi ishika
start = 2
end = 10
until start < end
  if end % start == 0
    say start
  start = start + 1
end

Problem: Find if the number is prime or not

  • sample
10 = no
7 = yes
  • Solution
Hi ishika
start = 2
number = 17
until start < number
   if number%start == 0
      say number is not prime
      exit
   start = start + 1
end 
say number is prime

Installation for Local dev setup

  • Ensure Git is installed
  • Ensure Terminal is configured
  • Ensure Python is installed
  • Ensure Visual Studio code is installed
  • Add Python Extension to Visual studio code
  • Navigate to Github.com and create a account if you dont have one.
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
Plugin for Social Media by Acurax Wordpress Design Studio
Exit mobile version
%%footer%%