Friday, 28 January 2022

Python practice programs for beginners - Day4

 

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.

1 comment :