Python Basics for Beginners
文章平均质量分 62
Python Basics for Beginners
BOTONECK
Keep learning...
Make sober all the time!
展开
-
break & continue & pass for loop
Loop control statements change the normal flow of execution. It is used when you want to exit a loop or skip a part of the loop based on the given condition. It also knows as transfer statements.Now, let us learn about the three types of loop control sta原创 2022-05-24 05:05:09 · 187 阅读 · 0 评论 -
if-else in for loop
In this section, we will use how to use if-else statement with a loop. If-else is used when conditional iteration is needed. For example, print studetn names who got more than 80 percent.The if-else statement checks the condition and if the condition is原创 2022-05-24 05:05:26 · 182 阅读 · 0 评论 -
for loop with range()
The range() function returns a sequence of numbers starting from 0 (by default) if the initial limit is not specified and it increments by 1 (by default) until a final limit is reached.The range() function is used with a loop to specify the range (how ma原创 2022-05-15 13:42:16 · 157 阅读 · 0 评论 -
Python for loop
In this article, you'll learn what is for loop in Python and how to write it. We use a for loop when we want to repeat a code block a fixed number of times.A for loop is a part of a control flow statement which helps you to understand the basics of Pytho原创 2022-05-15 11:55:46 · 416 阅读 · 0 评论 -
Nested if-else statement
In Python, the nested if-else statement is an if statement inside another if-else statement. It is allowed in Python to put any number of if statements in another if statement.Indentationis the only way to differentiate the level of nesting. The nested..原创 2022-05-15 10:57:37 · 238 阅读 · 0 评论 -
Chain multiple if-elif-else statement
In Python, the if-elif-else condition statement has an elif blocks to chain multiple conditions one after another. This is useful when you need to check multiple conditions.With the help of if-elif-else we can makea tricky decision. The elif statement ..原创 2022-05-15 10:54:15 · 122 阅读 · 0 评论 -
If-else statement
The if - else statement checks the condition and executes the if block of code when the condition is True, and if the condition is False, it will execute the else block of code.Syntax of the if - else statementif condition: statement 1else: s原创 2022-05-15 10:51:07 · 130 阅读 · 0 评论 -
If statement
In control statements, the if statement is the simplest form. It takes a condition and evamuates to either True or False.If the condition is True, then the True block of code will be executed, and if the condition is False, then the block of code is skep原创 2022-05-15 10:49:04 · 140 阅读 · 0 评论 -
Python Control Flow Statements
In Python programming, flow control is the order in which statements or blocks of code are executed at runtime baed on a condition.Control Flow StatementsThe flow control statements are divided into three categories:Conditional statements Iterativ原创 2022-05-15 02:57:57 · 370 阅读 · 0 评论 -
Control Flow and Loops
In Python, flow control is the order in which statements or blocks of code are executed at runtime based on a condition. The loop statement repeats a code block a number of times.Learn to use loops, conditional statements, iterative statements, and trans原创 2022-05-15 00:38:40 · 221 阅读 · 0 评论 -
String type conversion
In str type conversion, we use the built-in funtion str() to convert variables of other types to a string type. This function returns the string type of object (value).Casting int to str typenum = 11print(type(num)) # class 'int'# convert int to原创 2022-05-15 00:22:44 · 95 阅读 · 0 评论 -
Bool type conversion
We use the built-in function bool() to convert valus of other types of bool types. This function returns two valus, either True or False.We can convert any type of values to bool type, and the output for all values will be True, except 0, which is False.原创 2022-05-15 00:22:26 · 105 阅读 · 0 评论 -
Complex type conversion
In complex type conversion, we use the built-in function complex() to convert values from other types to the complex type. Value can be any type including of int, float, bool, and str.The complex funciton has the following two forms for conversion.comp原创 2022-05-14 22:16:10 · 91 阅读 · 0 评论 -
Int & Float type conversion
In int type conversion, we use the int() function to convert variables of other types to int type. Variable can be of any type such as float, string, bool.While performing int type conversion, we need to remember the following points.When converting st原创 2022-05-14 20:38:46 · 102 阅读 · 0 评论 -
Python Type Conversion or Type Casting
In Python, we can convert one type of variable to another type. This conversion is called type casting or type conversion.In casting, we convert variables declared in specific data types to the different data types.Python performs the following two typ原创 2022-05-14 19:23:19 · 155 阅读 · 0 评论 -
Bool & other data type
Bool data typeIn Pythin, to represent boolean values (True and False) we use the bool data type. Boolean values are used to evaluate the value of the expression. For example, when we compare two values, the expression is evaluated, and Python retuns th原创 2022-05-14 13:57:11 · 100 阅读 · 0 评论 -
Dict & Set data type
Dic data typeIn Python, dictionaries are unordered collections of unique values stored in (Key-Value) pairs. Use a dictionary data type to store data as a key-value pair.The disctionary type is represented using a dict class. For example, if you want原创 2022-05-14 03:03:49 · 111 阅读 · 0 评论 -
List & Tuple data type
List data typeThe Python List is an ordered collection (also known as a sequence) of elements. List elements can be accessed, iterated, and removed according to the order they inserted at the creation time.We use the list data type to represent group原创 2022-05-14 02:24:28 · 100 阅读 · 0 评论 -
Float & Complex data type
Float data typeTo represent floating-point values or decimal values, we can use the float data type. For example, if we want to store the salary, we can use the float type.The float type in Python is represented using a float class.We can create a原创 2022-05-14 01:53:21 · 138 阅读 · 0 评论 -
Str & Int data type
Str data typeIn Python, a string is a sequence of characters enclosed within a single quote or double quote. These characters could be anything like letters, numbers, or special symbols enclosed within double quotation marks. For example, "Python" is a原创 2022-05-14 01:23:03 · 121 阅读 · 0 评论 -
Python Data Types
Data types specify the differrent sizes and values that can be stored in the variable. For example, Python stores numbers, strings, and a list of values using different data types.Python is a dynamically typed language. Therefore, we do not need to speci原创 2022-05-14 00:47:28 · 188 阅读 · 0 评论 -
Variable‘s case-sensitive
Python is a case-sensitive language. If we define a variable with names a = 100 and A = 200 then, Python differentiates between a and A. These variable are treated as two different variable (or objects).Example:a = 100A = 200# value of aprint(a) #原创 2022-05-14 00:08:21 · 100 阅读 · 0 评论 -
Delete a variable
Use the delkeyword to delete the variable. Once we delete the variable, it will not be longer accessible and eligible for the garbage collector.Example:var1 = 100print(var1) # 100Now, let's delete var1 and try to access it again.Example:var1..原创 2022-05-13 22:48:33 · 80 阅读 · 0 评论 -
Get the data type of variable
No matter what is stored in a variable(object), a variable can be any type like int, float, str, list, tuple, dict, etc. There is a built-in function called type() to get the data type of any variable.The type() function has a simple and straight forward原创 2022-05-13 22:30:57 · 74 阅读 · 0 评论 -
Create Number, String, List variables
We can create different types of variables as per our requirements. Let's see each one by one.NumberA number is a data type to store numeric values. The object for the number will be created when we assign a value to the variable. In Python3, we can原创 2022-05-13 02:32:03 · 172 阅读 · 0 评论 -
Changing the value of a variable
Many programming languages are statically typed languages where the variable is initially declared with a specific type, and during its lifetime, it must always have that type.But in Python, variables are dynamically typed and not subject to the data typ原创 2022-05-13 02:18:46 · 84 阅读 · 0 评论 -
Creating a variable
Python programming language is dynamically typed, so there is no need to declare a variable before using it or declare the data type of variable like in other programming languages. The declaration happens automatically when we assign a value to the variab原创 2022-05-13 02:09:12 · 76 阅读 · 0 评论 -
Variables and Data Types
To learn how to create, modify, delete variables of different types. Learn to use some basic numeric (int, float, and complex), string, and Boolean types that are built into Python.For example, we can create a variable with a specific name. Once you crea原创 2022-05-13 01:49:37 · 86 阅读 · 0 评论 -
Create and Run Your First Python Program
Now, the installation is completed. Let's see how to write our first Python program.We can run Python by using the following three ways:#1 Run Python using IDLE ( Integrated Development Environment )#2 Run Python interactively using command line in i原创 2022-05-13 01:31:37 · 87 阅读 · 0 评论 -
Install Python
It may be possible that some PCs and Macs will have Python already installed. You can check which version of Python is installed before proceeding to the installation.Open the CMD-Command line to termnal and type the below command.python -- versionI原创 2022-05-13 01:20:22 · 93 阅读 · 0 评论 -
An Introduction to Python
This section will help you get started with Python Programming language by installing it and running your first program. Also, it will walk you through the basic concepts and fundamentals of Python.We need to download Python software from Python web port原创 2022-05-13 01:03:09 · 116 阅读 · 0 评论 -
Python Basics for Beginners (Manual Input)
This Python essential exercise is to help Python beginners to learn necessary Python skills quickly. Practice Python basic concepts such as loops, control flow, data types, operatiors, list, string, input and output, and built in functions.Here we learn原创 2022-05-13 00:48:18 · 113 阅读 · 0 评论