Skip to content

data-girlCode/Tech4Dev-python-holiday-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tech4Dev-python-holiday-project

This is a Python project worked on using Jupyter There are three exercises given to us. here are the questions for each exercise.

EXERCISE 1

  1. What is the output of the following print statements? print("\ta\tb\tc") print("\") print("'") print(""""")

print("C:\nin\the downward spiral")

  1. Write a print statement to produce this output: / \ // \ /// \

  2. What print statements will generate this output? This quote is from Irish poet Oscar Wilde: "Music makes one feel so romantic at least it always gets on one's nerves – which is the same thing nowadays."

  3. What print statements will generate this output? A "quoted" String is 'much' better if you learn the rules of "escape sequences." Also, "" represents an empty String. Don't forget: use " instead of " ! '' is not the same as "

  4. What values result from the following expressions? – 9 / 5 – 695 % 20 – 7 + 6 * 5 – 7 * 6 + 5 – 248 % 100 / 5 – 6 * 3 - 9 / 4 – (5 - 7) * 4 – 6 + (18 % (17 - 12))

EXERCISE 2

SOFTWARE DEVELOPMENT – List, Tuple Python programming exercises

  1. Write a program that finds the maximum value of the given list, assuming that the list contains at least one element. Try your program with the following array: 2, 4, 7, 4, 23, 5, 1, 4, 8, 9

  2. Write a program that calculates the average value of the given list. Try your program with the following list: 4, 7, 1, 5, 11, 53, 12, 46, 84, 23

  3. Write a program that prints the given list of integers in reverse order. Try your program with the following list: 2, 6, 7, 45, 23, 53,14, 45, 89, 5

  4. Write a program that accepts two lists of integers and prints true if each element in the first list is less than the element at the same index in the second list. Your program should print false if the lists are not the same length.

  5. Write a program that accepts a list of integers and two indexes and swaps the elements at those indexes

  6. Write a program that accepts two lists of integers and prints a new list containing all elements of the first list followed by all elements of the second.

  7. Write a program that accepts a list of integers and an integer value as its parameters and prints the last index at which the value occurs in the list. The program should print –1 if the value is not found. For example, in the list [74, 85, 102, 99, 101, 85, 56], the last index of the value 85 is 5.

  8. Write a program that prints the range of values in a list of integers. The range is defined as 1 more than the difference between the maximum and minimum values in the list. For example, if a list contains the values [36, 12, 25, 19, 46, 31, 22], the program should return 35. You may assume that the list has at least one element.

  9. Write a program that accepts a list of integers, a minimum value, and a maximum value and prints the count of how many elements from the list fall between the minimum and maximum (inclusive). For example, in the list [14, 1, 22, 17, 36, 7, -43, 5], for minimum value 4 and maximum value 17, there are four elements whose values fall between 4 and 17.

  10. Write a program that accepts a list of real numbers and prints true if the list is in sorted (nondecreasing) order and false otherwise. For example, if lists named list1 and list2 store [16.1, 12.3, 22.2, 14.4] and [1.5, 4.3, 7.0, 19.5, 25.1, 46.2] respectively, the program should print false for list1 and true for list2 respectively. Assume the list has at least one element. A one-element list is sorted.

About

This is a python project worked on using Jupyter notebook

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published