Python KodeKloud Beginner’s Course:
Types of Data:
Python had 3 types of data. They are essential when you want store any infrmation that is received
whilst running the code.
Operators:
Python has different operators which help us to perform arithmetic actions. They are similar to the
regular arithmetic but they differ near some.
print(10**2) # exponent
print(10*2) # multiply
print(10//2) #floor division
print(36%7) # modulo fn - gives remainder after di
vision
Practice me: Here are some questions on the basic use of some operators.
print(6.//4)
print(13 / 4 + 13 % 4)
print(9 % 4)
Also cannot be any of the following reserved keywords:
Practice me!
print(20/5*4)
print(10 - 6 ** 2 / 9 * 10 + 1)
print(6. // 4)
x=10/4
y=5/2.0
print(x+y)
New Function:
age= input("What is your age?") # input function allows
us to take in data from the user.
print(age) # You can store that data in a variable and
can later use it.
Try me out!
age=input("What is your age: ")
print("Your age is"+ age)
number=input("Enter the number of years you want to tim
e travel in future: ")
final=int(age)+int(number)
print(final)
Comparision factors: New
print(2==2) # Here == means equal to.
print(2!=2) # Here != means not equal to.
Conditional statements: They are lines of code that get excecuted if the condition provided is true. If
the condition turns out to be false, that set of code gets ignored and the rest of code is excecuted by
python.
Ex: Try me!
age=int(input("How old are you?"))
if age>=18:
print("You are an adult!")
if age <=18:
print("You are a kid!")
The same code can also be altered with another function namely: else
age=int(input("How old are you?"))
if age>=18:
print("You are an adult!")
else:
print("You are a kid!")
You will be receiving the same output in both the cases .
While condition
secret_number=3
guess=int(input("Guess the secret number from 1 to 5!")
)
while guess!=secret_number:
guess=int(input("Try again friend!"))
else:
print("Congratulations! You got it correct!")
user=input("What is your name?")
username=input("Set a username for yourself")
password=input("Enter a password")
print("Welcome to name generator. Here is where we gene
rate names for aspirers of any age and gender.")
food=input("What is the last thing that you have consum
ed?")
color=input("What is the color of your shirt or your dr
ess?")
print("The new name is "+food+color+"!")
Small sample code for print, input.
And is a alternative for using the if iterative. It works mostly like the negative sign in mathematics.
Or is another value similar to and. This returns the value of true even if one is false.
Not basically refers to the complete opposite of what is being asked.
Bitwise operators are also operators which give out value in 1 and 0 namely.
The shortcuts of all bitwise operators:
When we move the bits in the operators, we get different values. Some of the most common ones
are:
Mostly about operators