DEV Community

KAPIL SHAH
KAPIL SHAH

Posted on

Day-01 of learning python

I learned some basic stuffs in python programming language

LIKE:::

1.airthmetic operators:

Enter fullscreen mode Exit fullscreen mode


python
x=10
x=x+3
x +=3

Enter fullscreen mode Exit fullscreen mode

2.comparison process in this language:

# x=3!=2
# print(x)
# >
# >=
# <
# <=
# ==
# !=
Enter fullscreen mode Exit fullscreen mode

3.for loops:

numbers=[1,2,3,4,5,6]
# print(numbers)
for item in numbers:
    print(item)

i=0
while i<len(numbers):
  print(numbers[i])
  i=i+1

Enter fullscreen mode Exit fullscreen mode

4.if statement :



temp = 25


if temp > 30:
    print("It's hot bebe")
elif temp > 20:
    print("not hot")
Enter fullscreen mode Exit fullscreen mode

5.lists :

We can say that list is mutability which means that we can insert the element even after the creation at first.

taking example :

There are three basic types from which we can define properly that what exactly is list and its use:::

1.insert() : we can insert any data or element in the square bracket :

# Insert

fruits.insert(1, "banana")
print(fruits)  # Output: ['apple', 'banana', 'blueberry', 'cherry', 'date']
Enter fullscreen mode Exit fullscreen mode

2.Append (): this helps to insert the data at the last of the list :

# Append
fruits.append("date")
print(fruits)  # Output: ['apple', 'blueberry', 'cherry', 'date']

Enter fullscreen mode Exit fullscreen mode

3.Extend(): This helps to Extend the list

taking an example::

# Extend
more_fruits = ["elderberry", "fig"]
fruits.extend(more_fruits)
print(fruits)  # Output: ['apple', 'banana', 'blueberry', 'cherry', 'date', 'elderberry', 'fig']
Enter fullscreen mode Exit fullscreen mode

for mutual extend example we see that:

list1 = [1, 2, 3]
list2 = [4, 5, 6]

list1.extend(list2)
print(list1)  # Output: [1, 2, 3, 4, 5, 6]
Enter fullscreen mode Exit fullscreen mode

from above example we see that list1 just got extended because of addition of list2

6.Logical operator:

# price = 25
# print( not price > 10 )
# and(both)
# or(atleast1)
Enter fullscreen mode Exit fullscreen mode

7.Receiving inputs ::

name = input("What is your name?")
print("Hello "  + name)
Enter fullscreen mode Exit fullscreen mode

8.strings

sentence=("kops the great")
print(sentence.replace('the','is'))

print(sentence.find('the'))
print(sentence.upper())
print(sentence.lower())
print(sentence.casefold)
print(sentence.endswith('true bitch'))
print('python' in sentence)
print('the' in sentence)
Enter fullscreen mode Exit fullscreen mode
  1. Kind of range and function::
numbers=[1,2,3,4,5,6]
# numbers.clear()
print(10 in numbers)
Enter fullscreen mode Exit fullscreen mode

10.Type conversion(Most important)

# birth_year= input("Enter your data of birth:")

# age = 2020 - int(birth_year)
# print(age)    

num1=input("FIRST NUM:")
num2=input("SECOND NUM:")
sum= float(num1)+float(num2)
input("Sum is : " + str(sum))
Enter fullscreen mode Exit fullscreen mode

It helps a lot in large program so it is most necessary to understand about These concept .

11.Variable(Kind of a container where different types of data are stored) ::


patient_name="jhon smith"
age ="20"
patient_type="New patient"
print("patient name is :",patient_name)
print( "age is :",age)
print("patient is:", patient_type)
Enter fullscreen mode Exit fullscreen mode

Here patient _name ,age, patient_type is a variables::

Question times::

1.Suppose you were given a number either in kg or pound. If it is kg the convert it to pound and vice versa.

And print the statement in proper format

Incase you are having a problem on this the check it out pls>>

weig = float(input("Weigth:"))
conversion= input("kg or lbs")

if conversion == "kg":
     result=weig/0.45
     print("The weight in lbs is:" + str(result))
else :
    result = weig*0.45
    print("The weight in kg is :" + str(result))
Enter fullscreen mode Exit fullscreen mode

NOTE :: OUTPUT ARE NOT GIVEN ABOVE SO YOU HAVE LOOK FOR THIS YOURSELF IN ANY COMPILER .

THANK YOU AND THAT”S FOR THE DAY 1.

Top comments (1)

Collapse
 
prashantcod profile image
Prashant Gyawali

Awesome!!! A step ahead to success