Module 1 ICP 2: Loops, List, Tuples, Functions in python - acikgozmehmet/PythonDeepLearning GitHub Wiki

Objectives:

The following topics are covered.

  1. loops: for and while statements.
  2. Interactive loop and sentinel loop: implementations using while statement
  3. Nested loop
  4. Reading from a file in loop
  5. Tuples
  6. Set
  7. dictionaries
  8. Use case

Overview

  1. Working with for loops
  2. Working with Tuples, Lists, Functions
  3. Various kinds of Loops: definite and indefinite loops, using files in loops, Nested Loops

In Class Programming

• Write a program, which reads weights (lbs.) of N students into a list and convert these weights to kilograms in a separate list using:

  1. Loops and

  2. List comprehensions

    N: No of students (Read input from user)

    Ex: L1: [150,155, 145, 148]

    Output : [68.03, 70.3, 65.77, 67.13]

Click here to get the source code

2. Write a program that returns every other char of a given string starting with first using a function named “string_alternative”

 Str = “Good evening”

 Output: Go vnn

Click here to get the source code

3. Write a python program to find the wordcount in a file for each line and then print the output. Finally store the output back to the file.

Input: a file includes two line

Click here to get the source code

References

https://github.com/wade12/ProgrammingForBigDataCA2CarRental/blob/master/carRentalApp.py

http://www.w3resource.com/python-exercises/python-conditional-statements-and-loop-exercises.php

https://www.learnpython.org/