## 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.

Get a number from the user and find whether the given number is an odd number or an even number.

## Python practice programs for beginners - Day9

Day 8 solution:

 Program

x and y is False
x or y is True
not x is False
Solution

Day 9:

if statement:

Syntax:

if condition:
#Statements to be executed once the condition is True

Example:

number=10

if  number>0:
print("The number is positive")

Output:
The number is positive

Try to get two single-digit numbers from the user then add the two numbers and if the addition of those two numbers is above 10 then print "You score greater than 10". If the addition is below 10 then print "You score less than 10".

Will see the solution in next post.

## Python practice programs for beginners - Day8

Day 7 Solutions:

a=int(input("Enter the number: "))
b=int(input("Enter the number: "))
print(f'{a} is greater than ">" {b} True or False? Result:{a>b}')
print(f'{a} is Lesser than "<" {b} True or False? Result:{a<b}')
print(f'{a} is equals to "==" {b} True or False? Result:{a==b}')
print(f'{a} is not equals to "!=" {b} True or False? Result:{a!=b}')
print(f'{a} is greater than or equals to ">=" {b} True or False? Result:{a>=b}')
print(f'{a} is lesser than or equals to "<=" {b} True or False? Result:{a<=b}')

Output:

Enter the number: 4
Enter the number: 4
4 is greater than ">" 4 True or False? Result: False
4 is Lesser than "<" 4 True or False? Result: False
4 is equal to "==" 4 True or False? Result: True
4 is not equal to "!=" 4 True or False? Result: False
4 is greater than or equals to ">=" 4 True or False? Result: True
4 is lesser than or equals to "<=" 4 True or False? Result: True

Day 8: Logical Operator

Logical Operators helps us to check more than one condition at a time.

we have 3 operators.

and - returns True when both operands return true else false

or - returns True if at least one of the operands is true.

not - returns True if the specified condition is not met.

and Operator:

Example:

a=10

b=10

c=10

a==b and a==c --> True

(True) and (True) --> True

a=11

b=10

c=10

a==b and a==c --> False

(False) and (True) --> False

or Operator:

a=11

b=10

c=10

a==b and a==c --> False

(False) and (True) --> True

not Operator:

not(b==c)

not(True) --> False

Task: Try to use these operators and check various conditions.

## Python practice programs for beginners - Day7

Day 6 Program:

### Output:

Day 7:

Relational Operators:

== --> Equals
!= --> Not Equals
> --> Greater than
< --> Lesser than
>= --> Greater than or equals
<= --> Lesser than or equals

Relational operators in python or comparison operators in python are used to find the relationship between 2 numbers/variables.

This expression will return Either True or False depending on the expression we use.

### Example:

a=10
b=20
a==b i.e  10==20

Output = False

Since 10 and 20 are not equals we get the result as False.

Try out all the relational operators along with the string formatting concept learned on Day 6.

### Example:

The output will be displayed in the next post.

## Python practice programs for beginners - Day6

Welcome to the 30-day challenge of Python practising for beginners.

### Day 5 practice program:

Practice all the Arithmetic Operators given:

### Arithemtic Operators:

Subtraction --> -
Multiplication --> *
Division (Quotient) --> /
Division (Remainder) --> %
Exponentiation --> **
Floor Division --> //

### Day 6:Formatting:

In the above output, you can see the output are getting displayed but it is not that clear to the user.

So we will use String formatting.

### Output:

Try to apply the formatting to all the other arithmetic operators.

The output will be displayed in the next post.

## Python practice programs for beginners - Day5

Welcome to the 30-day challenge of Python practising for beginners.

Day 4 practice program:

The solution is similar to that of the sample program discussed.

### Operators:

Operators are something that helps us to work with operands.
There are more operators in python.
In this post, we will try to learn the Arithmetic operator.

Arithemtic Operators:

Subtraction --> -
Multiplication --> *
Division (Quotient) --> /
Division (Remainder) --> %
Exponentiation --> **
Floor Division --> //

Example:

a=int(input("Enter the number"))
b=int(input("Enter the number"))
print(a+b)

Output:

### Day 5 Practice:

Practice all the Arithmetic Operators given above.

The output will be displayed in the next post.

## Python practice programs for beginners - Day4

Welcome to the 30-day challenge of Python practising for beginners.

Day 3 practice program:

Day 3 Solution:

Program:

Solution:

### Day 4:

Type Casting:

In the above example if you have noticed we got 2 inputs from the user.

Name and Age, where name is a String and Age is a number but in the above output, you can see that is also String.

To convert one type of data into another type we need to do Type Casting.

Syntax:

type_name(variable)

Example:

Program:

Output:

So after typecasting, you can see that the type of Age variable is int which is a number.

### Practice Program Day 4:

Write a program:

--> Get different data about a person

--> Find the type of data getting stored

--> Try to change the type of a variable and print it