Python Classroom notes 29/Aug/2024

Style Guide (PEP-8)

  • Google’s python style guide is also used by many organizations Refer Here
  • Lets focus on comments and Docstrings

Comments and Docstrings

  • Refer Here for specific section of comments and doc string
  • To enable google docstrings in visual studio code lets install an extenstion autodocstring

  • Use this extension to generate docstrings

Operators (contd..)

  • Refer Here for operators docs
  • Assignment operators
  • Comparision Operators
  • Logical Operators
  • Refer Here for notebook

Spacing in python

  • In python we would come across lines and blocks (sequence of lines), python has a very strict spacing rule

Useful Functions

  • input
input

conditional statements in python

  • Refer Here for docs
  • Conditionals
    • if
    • if else
    • if elif else
    • nested if statmements
  • syntax
if <conditional expression> :
    <block>
  • Hacker Rank Problem
Task
Given an integer, , perform the following conditional actions:

If  is odd, print Weird
If  is even and in the inclusive range of  to , print Not Weird
If  is even and in the inclusive range of  to , print Weird
If  is even and greater than , print Not Weird
Input Format

A single line containing a positive integer, .

Constraints

Output Format

Print Weird if the number is weird. Otherwise, print Not Weird.

Looping statements in python

while <conditional expression>:
   block
  • Refer Here for the some of the problems solved in the class.
Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a ReplyCancel reply

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

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Exit mobile version
%%footer%%