Skip to playerSkip to main content
  • 6 months ago
Transcript
00:00Getting started with Python
00:02The concepts are
00:11Introduction to the topic
00:13Variables
00:14Dynamic typing
00:16Simple input and output
00:18Recapitulation of the topic
00:20Here is a simple Python program.
00:25Isn't it quite tedious to understand the code?
00:27The basic structure of a Python program contains various components like expressions, statements, comments, function, blocks and indentation.
00:39Now let's discuss these further.
00:43An expression is any legal combination of symbols that represents a value.
00:49An expression is evaluated and then produces a value.
00:52A statement is a programming instruction that executes some action.
00:59Following are some examples of statements.
01:03Comments are the additional readable information which is read by the programmers but ignored by a Python interpreter.
01:11In Python, comments begin with symbol hash and end with the end of physical line.
01:16A function is a named block of code that can be reused by specifying its name in the program where needed.
01:26A group of one or more statements is called block or suite.
01:31Unlike many programming languages such as C, Java, etc. that use curly brackets to show blocks, Python rather uses indentation.
01:40A variable in Python denotes a memory location that stores some value.
01:47A variable gives data to the computer for processing.
01:51In Python, to create a variable, just assign to its name the value of appropriate type.
01:57For example, to create a numeric variable, assign a numeric value to variable name and so on.
02:04L values are the objects to which we can assign a value or expression.
02:11R values are the literals and expressions that are assigned to L values.
02:17Here, A and B are L values, whereas 20 and 10 are R values.
02:24We can assign same value to multiple variables in a single statement.
02:28We can even assign multiple values to multiple variables in a single statement.
02:34It will assign the values order-wise.
02:37That is, first variable is given first value, second variable the second value and so on.
02:44A variable is created only when we assign some value to it.
02:49To understand it, consider the following code fragment.
02:52When we run the code, it will produce an error.
02:55Using an undefined variable in an expression or statement causes an error called name error.
03:03Dynamic typing is a feature of Python in which a variable pointing to a value of a certain type
03:09can be made to point to a value of different type.
03:14On the basis of concept learnt, try to answer the questions.
03:19Choose the correct option from the given options.
03:25Choose the correct option from the given options.
03:38In Python, input from user is taken by using built-in function input
03:43and to send output to standard output devices, another built-in function, print, is used.
03:51The built-in function input is used in the following manner to obtain the input from the user.
03:58In above code, we used input function to input two values.
04:02In this example, error is shown because the input function always returns a value of string type
04:10because whatever value we enter through input function is treated as string.
04:15But what to do if we have to read numbers?
04:19In this case, Python offers two functions to be used with input function to convert the values received into int and float types.
04:29The print function is a way to send output to monitor.
04:34The syntax to use print function is as follows.
04:36Now consider some print statement examples and their output.
04:44On the basis of concept learnt, try to answer the questions.
04:49Let's go through some project work.
04:54Can you predict the output of following code fragment?
04:57Write a program to input two numbers and print their sum.
05:09Here is a program to input two numbers and print their sum.
05:12The output is as follows.
05:15Let us recapitulate the concepts.
05:18A statement is a programming instruction that executes some action.
05:23A variable can be assigned to a literal or to an expression.
05:26Dynamic typing is a feature of Python in which a variable pointing to a value of a certain type
05:33can be made to point to a value of different type.
05:56a solution, an expression kind of the type oficon.
06:14manner of behaviority.
06:18The output is a visual a built-in relationship.
Be the first to comment
Add your comment

Recommended