Python practice programs for beginners - Day 19

Day 18: Solution

Day 19: Getting list items from users at run time and printing it.

You can practice the above program.

Day 19 Task: Get the Hollywood movie list going to get released in 2022 Summer from the user and print it.

Python practice programs for beginners - Day 18

Day 17 Solution:

Day 18: Introduction to List

A list is a collection of items. The items can be of any type.

Example: [1,2,3,5.5,"a",True]

How to print a list in Python?

Output:

[1, 2, 3, 4, 5.5, True]

But if we want to print the list items alone we need to use for loop.

Output:

1

2

3

4

5.5

True

Day 18 Task: Create a list for latest gadgets and display it.

Python practice programs for beginners - Day 17

Day 16: Solution

Output:

Day 17: While loop

Syntax:

while condition to check:

statement to be executed

Example:

Get a number from the user and print the odd numbers in that range.

Python practice programs for beginners - Day 16

Day 15 Solution:

Output:

Day 16: For Loop

Mini Project 2:

Get a number from the user and display the multiplication table of that number. You can also get them up to which number you can display the table.

Python practice programs for beginners - Day 15

Day 14 Solution:

Output:

Day 15 : for loop

If you see in the above picture the output is starting from 0 and ending with 9. If we want to start from 1 to 10 then we need to change the code in the range.

In this we have to use from 1 to 11 (10+1) because the loop runs from 1 to whatever the value mentioned at end position -1.

Output:

Get start value and end value from the user at run time and print all the even numbers between that range.

Python practice programs for beginners - Day 14

Day 13 Solution:

Python Grade Checker Project Source Code:

Day 14: for loop

Syntax:

for val in sequence:

statements to be expected in the loop

val - variables

sequence - may be a range or list of items

Example:

Output:

Python practice programs for beginners - Day 13

Welcome to Day 13 of the 30 days Challenge.

Day 12 Solution:

Day 13:

So far we have practised on

1. Variables
2. Operators
3. Control statements
4. String formatting

with the help of all these try to do the below task:

Get a student details such as:

Name:

School/College:

City:

Subject 1 mark :

to

Subject 5 mark:

Then calculate the following details and display them:

Total:

Average:

Pass/Fail:

Grade Calculation based on Average value:

91 to 100 - A+

86 - 90 - A

80 - 85 - B+

79 - 84 - B

70 - 78 - C

60 - 69 - D

50 - 58 - E

Below 50 - F

Sample Output:

Will see the solution in the next post.

Python practice programs for beginners - Day 12

Day 11 solution:

Output:

Day 12: String Format

In the above program instead of using

print(number3," is the greatest number")

We can use

print(f'{number3} is the greatest number')

f --> format

' --> single apostrophe used to say that it follows String formatting.

{} -->  we can use the curly braces for the placeholders where we can mention the variable name.

Try to reprogram the above logic using String formatting.

Python practice programs for beginners - Day 11

Day 10 Solution:

Day 11: If elif

If we want to check more scenarios we can use if elif

Syntax:

if condition 1:

Statement to be executed if the condition is True

elif condition 2:

Statement to be executed if the condition is True

elif condition 3:

Statement to be executed if the condition is True

Day 11 Task: Get three numbers from the user and try to find the smallest of those three numbers.

Python practice programs for beginners - Day 10

Day 9 Solution:

Day 10:  If-Else statement

In the above, we have used two if statements but we can reduce the number of lines of code by using an else statement.

You can see the number of lines of code decreased.

The If else get applied in many scenarios.