Showing posts with label 2022. Show all posts
Showing posts with label 2022. Show all posts

Monday, 7 February 2022

Python practice programs for beginners - Day 10

2 comments :

 

Python practice programs for beginners- millioninformations


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.


Day 10 Task:

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


Read More

Python practice programs for beginners - Day9

1 comment :

 

Python practice programs for beginners - millioninformations


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


Task:

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.









Read More

Python practice programs for beginners - Day8

1 comment :

 

Python practice programs for beginners - millioninformations


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.








Read More

Tuesday, 1 February 2022

Python practice programs for beginners - Day7

1 comment :

 

Python practice programs for beginners - millioninformations


Day 6 Program:

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


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.

Day 7 Task:


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

Example:




Try to complete the task.

The output will be displayed in the next post.
Read More

Python practice programs for beginners - Day6

1 comment :

 

Python practice programs for beginners - millioninformations

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

Day 5 practice program:

Practice all the Arithmetic Operators given:

Arithemtic Operators:


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

Program:



Output:




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.

Syntax:


print(f'yout text {your variable}')


Example:



Output:




Day 6 Task:


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

Try to complete the task.

The output will be displayed in the next post.



Read More

Python practice programs for beginners - Day5

1 comment :

 

Python practice programs for beginners - millioninformations

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.  

Day 5:

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:

Addition --> +
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.

Try to complete the task.

The output will be displayed in the next post.
Read More

Friday, 28 January 2022

Python practice programs for beginners - Day4

1 comment :

 

Python practice programs for beginners - millioninformations

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

Try to complete the task.

The output will be displayed in the next post.
Read More

Thursday, 27 January 2022

Python practice programs for beginners - Day3

1 comment :

 

Python practice programs for beginners - millioninformations

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

Day 2 Practice Program:

Day 2 Solution:

Program:


Output:



Get Input from user:

So far, we have given the value to the variable in coding itself. Now we will try to get the input from the user at run time.

use input() function to get the input.

Program: 


Output:



Practice program 3:

    Try to use this input() to the previous program and provide the input at the run time.

--> Get the input from the user

--> Print the values

--> Print the type of variables.

Try to complete the task.

The output will be displayed in the next post.


Read More

Wednesday, 26 January 2022

Python practice programs for beginners - Day2

1 comment :

 

Python practice programs for beginners - millioninformations


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


Day 1 Practice Program:

Day 1 Solution:


Python practice programs for beginners - Day2

Data types:

In the previous post, we practised variables. In this post, we will practice data types. 

The type of data we are storing in the variable is called Data type.

Text kind of data is called as String, whole numbers such 5, 10 are called as Integers. Decimal valued data are called the float. True or False kinds of data are called Boolean.

to check the type of your data stored in the variable you can use type(variable_name) inside the print function.

Example:

Python practice programs for beginners - millioninformations


Output: 


Practice Program - Day 2

Find the different types of data for the Day 1 program.

Also try to use Float, Boolean.

Try to complete the task.

The output will be displayed in the next post.


Read More

Python practice programs for beginners - Day1

No comments :

 

Python practice programs for beginners - Millioninformations


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


Python practice programs for beginners - Day1


Variables:

Variables are the most important concept in any programming language. It will help to store any data which we can use throughout the program.

Example: userName="millioninformations"

userName is the variable name and "millioninformations" is the value stored in that variable.

Rules for declaring Variables:

1.Variable must start with lowercase letter
2. Should not contain space or special characters.
3. Underscore can be used to connect two words
4. Also can follow camelCase (first words first letter in lower case and second words first letter in upper case)

Practice Program - Day 1

Write a Program to store a Student's details using the below variable names:

--> studentName
--> studentAge
--> studentGender
--> institute


Sample output:



Try to complete the task.

The output will be displayed in the next post.

If you are reading this post for the first time do read: 

Read More

Tuesday, 25 January 2022

How to run Python program

2 comments :

 

how to start with python programming - millioninformations


30 Days Python Practice Challenge for Beginners.

Python is the most powerful but simple programming language right now.

This Python practice program for beginners will help you to get confidence in the basics of Python programming.

Learn how to Install Python

Since we need to use Python you may also download Python or also can use online python compilers. For mobile users download the Pydroid 3 app or QPython 3L.


Method 1: Using IDLE in Laptop (Once Python Installed)

Once you have installed Python, let's open idle.

You can search IDLE in the windows search bar.

python idle - millioninformations


You can something like this once opened.





Click on File --> New File

You will get a file like this. In this, you can start practising the program.

Once you typed it, you can save it and run the program by clicking Run option.



Method 2: Using online Interpreter 

Easy to get started for beginners.

python online compiler - Interpreter


Method 3: Mobile App

For mobile users download the Pydroid 3 app or QPython 3L.









I hope now you can able to use any of the given methods to run your python program.

From next post we will be doing 30 day challenge for Python program practice. It will not be like tutorials instead you will be practicing the program and self analysing the output.

Read More