basic knowledge about python, Exercises of Programming Paradigms

basic knowledge about python basic knowledge about python

Typology: Exercises

2021/2022

Uploaded on 10/28/2022

thanh-duong-nhat
thanh-duong-nhat 🇻🇳

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Homework 1
Exercise 1. Use markdown mode in the Jupyter notebook to present your information on
top of your homework:
Full name:
Student id:
Class:
Exercise 2. Write a Python program to print the following string in a specific format (see
the output). Sample String : "Twinkle, twinkle, little star, How I wonder what you are! Up
above the world so high, Like a diamond in the sky. Twinkle, twinkle, little star, How I
wonder what you are"
Output :
Twinkle, twinkle, little star,
How I wonder what you are!
Up above the world so high,
Like a diamond in the sky.
Twinkle, twinkle, little star,
How I wonder what you are
Exercise 3. Write a Python program to print the following string in a specific format.
Output:
(Guide: google seach Python 3 Escape Sequences)
Exercise 4. Given a two integer numbers return their product and their sum
Given:
number1 = 40
number2 = 30
Expected Output:
The result:
pf3

Partial preview of the text

Download basic knowledge about python and more Exercises Programming Paradigms in PDF only on Docsity!

Homework 1

Exercise 1. Use markdown mode in the Jupyter notebook to present your information on

top of your homework: Full name: Student id: Class:

Exercise 2. Write a Python program to print the following string in a specific format (see

the output). Sample String : "Twinkle, twinkle, little star, How I wonder what you are! Up above the world so high, Like a diamond in the sky. Twinkle, twinkle, little star, How I wonder what you are" Output : Twinkle, twinkle, little star, How I wonder what you are! Up above the world so high, Like a diamond in the sky. Twinkle, twinkle, little star, How I wonder what you are

Exercise 3. Write a Python program to print the following string in a specific format.

Output: (Guide: google seach “Python 3 Escape Sequences”)

Exercise 4. Given a two integer numbers return their product and their sum

Given: number1 = 40 number2 = 30 Expected Output: The result:

Product: 1200 Sum: 70

Exercise 5. We’ll be building a small receipt printing program with the concepts we’ve

learned, in which the output will look like

Exercise 6. In Exercise 4 , we ended up creating borders above and below the information

printed out. Try adding a star border on the sides as well now.

Exercise 7. len() is a built-in function in python.You can use the len() to get the length of

the given string, array, list, tuple, dictionary, etc. Find the length of the following string: Sample String : "Twinkle, twinkle, little star, How I wonder what you are! Up above the world so high, Like a diamond in the sky. Twinkle, twinkle, little star, How I wonder what you are"

Exercise 8. Display “My Name Is James” as “MyNameIs**James” using output

formatting of a print() function Expected Output : Use print() statement formatting to display ** separator between each word. For example: print('My', 'Name', 'Is', 'James') will display MyNameIsJames