Friday, April 19, 2019

Python tutorial 2 - if statements and Strings

Welcome back, in this tutorial you will learn how to use if statements and variables.

 

Start off by creating a new file, name it whatever you wish.

For this program, you don’t need to import anything but I would recommend you

import os

import sys

import time

as it’ll save time in the long run when we work on more advanced programs.

 

A string is something the computer stores

example:Hacking A Rise Screenshot-68

In this example, the string variable1 is storing “Hello World”. you can use this to output something without writing it multiple times.

 

An if statement works by checking something and if it exists it will listen to the following code if it doesn’t exist, it will either end the program or look for an “else” statement.

 

if statement example:Hacking A Rise Screenshot-69

In this example, the computer will output “Hello World” because the if statement is true.

 

 

 

In the next python tutorial, I will be teaching how to set up a simple login interface using if statements, and strings.

 

Previous Tutorial

 

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.