Variable number of KEYWORD arguments Part 2

Variable number of KEYWORD arguments Part 2

Lesson Details:
June 29, 2020


I: Introduction

Python is a high-level programming language. It was created by Guido van Rossum. Python is an object-oriented programming language and supports multiple programming paradigms, including functional and imperative. Python features a dynamic type system and automatic memory management and supports multiple programming styles, including object-oriented, imperative and functional.



II: Body

Python has a simple syntax and contains many high-level built-in data structures; we’ll start with the basics of Python programming.



Variables in Python

Unlike most other languages, Python does not require explicit declaration of variables to reserve storage for them. When you use a variable in a program, Python creates it automatically. Once created, you can assign values to the variables using an assignment statement; the syntax of an assignment statement is:

variable = value



The following example shows a simple variable assignment in Python:

>>> myname = "Guido" >>> myname 'Guido'



In this example, we have created a variable named myname with a string value. After executing this statement, we can see that the value of myname is set to “Guido”.

You can also assign a new value to an existing variable using an assignment statement. This is called reassigning a variable. The following statement changes the existing value of myname from “Guido” to “Jeffrey”:

myname = "Jeffrey"



If you do not provide a value after the equal sign in an assignment statement, Python assumes that you intend to replace the existing value with a new one. For example, the following statements show two ways to change the value of myname from “Guido” to “Jeffrey”:

myname = "Jeffrey" myname = "Guido"



In addition to string values, Python variables can contain other types of values, such as integer values or floating point values. In addition to these basic types, Python supports complex types such as lists, tuples and dictionaries. We will cover them later in this tutorial.



Comments in Python

A comment in any programming language is used to document your code so that others can understand what your code does without having to look at the code itself. This is particularly helpful when you are working on large programs where it may be difficult to remember what you did six months ago. The syntax of a comment in Python is similar to other programming languages:

# This is a comment print("Hello, World!")



We should place comments on lines by themselves, beginning with either one or two hash marks (##). The first symbol signals the beginning of the comment; the second symbol signals the end of the comment. The following example shows two different ways to use comments in Python:

# This is a single line comment # # This is also a single line comment print("Hello World")



The first statement starts with one hash mark; it indicates that all characters up to the end of the line are part of the comment. The second statement starts with two hash marks; it indicates that everything between the two hash marks is part of the comment.

loader
Course content