CIT PYTHON COHORT THREE
  • CIT Python Cloud Software Engineering
  • week one
    • What is Python
    • Python Syntax
    • variables
    • Numbers / Integers
  • week Two
    • Control Flow Statements
      • If Statements
      • For Loops
      • While Loops
      • Break and Continue Statements
    • Operators
      • Assignment Operators
      • Arithmetic Operators
      • Comparison Operators
      • Logical Operators
      • Bitwise Operators
      • Identity Operators
      • Membership Operators
    • Data Types
      • Strings
      • Numbers
      • Booleans
      • Lists
      • Dictionaries
      • Tuples
      • Sets
  • Week 3
    • Functions
      • Function Arguments
      • Python Recursion
      • Python Anonymous/Lambda Function
    • Object Oriented Programming
      • Classes
      • Inheritance
      • Polymorphism
      • Abstraction
      • Encapsulation
    • Python Modules
      • Python Packages
      • Python Built-in Modules
      • Python Standard Library
      • Python Third Party Modules
    • Python Exceptions
      • Python Try Except
      • Python Raise
      • Python Assert
      • Python User-defined Exceptions
  • Week 4 - File Handling
  • Week6
    • Data Structures and Algorithms
      • DSA Introduction
      • What is an Algorithm?
      • Data Structures and Types
      • Stack
      • Queue
      • Linked List
      • Bubble Sort Algorithm
      • Selection Sort Algorithm
      • Insertion Sort Algorithm
      • Merge Sort Algorithm
      • Quick Sort Algorithm
  • Week8
    • Cryptography
      • Reverse Cipher
      • Caesar Cipher
      • Hash Functions
        • Applications of Hash Functions
        • Examples of Hash Functions
  • Assignments and Solutions
    • Loops
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
  1. Assignments and Solutions

Loops

  1. Print First 10 natural numbers using while loop.

  2. Calculate the sum of all numbers from 1 to a given number.

  3. Write a program to print multiplication table of a given number. eg if number is 2, then output should be 2, 4, 6, 8 ...

  4. Write a program to display only those numbers from a list that satisfy the following conditions

  • The number must be divisible by five

  • If the number is greater than 150, then skip it and move to the next number

  • If the number is greater than 500, then stop the loop given numbers = [12, 75, 150, 180, 145, 525, 50]

  1. Write a program to count the total number of digits in a number using a while loop. given number 4673453

  2. Display numbers from -10 to -1 using while loop

More Questions for Revision

  1. Write a program to print all the numbers from 1 to 100.

  2. Write a program to print all the numbers from 1 to 100 except multiples of 3.

  3. Write a program to print all alphabets from a to z.

  4. given a list of numbers, write a program to print all the numbers that are divisible by 5 and 7.

  5. using a for loop, create a pattern like this:

*
* *
* * *
* * * *
  1. Reverse a number using a while loop. given number 12345, output should be 54321.

  2. Find the sum of even numbers using a while loop

  3. Find the factorial of a number using a while loop. Hint: factorial of a number is the product of all the numbers from 1 to n. example number 5, output should be 120

PreviousAssignments and Solutions

Last updated 2 years ago

Was this helpful?