Posts

Showing posts from May, 2024

day #10- Strings_Silicing_and_Operation_On_Strings

Image
                                          ~  Strings_Slicing ~ program-1 input - names="hardik,Aman" print(names[0:6]) print(len(names))      # python always start with zero. output- hardik 14 prgram no.2 input- fruit= "Mango" mangolen = len(fruit) print(mangolen) print(fruit[0:4]) print(fruit[1:5]) print(fruit[:5]) print(fruit[0:-3]) output- 5 Mang ango Mango Ma program 3 pie="Applepie" print(pie[:5])            #slicing from start print(pie[5:])            #silicing till end print(pie[2:6])         #silicing in between  print(pie[-8:])         # silicing end negative index program 4 l oop through a String: string are arrays and arrays are iterable. Thus we can loop through strings. alphabets= "ABCDE" for i in alphabet:       print(i)...

day #9- String_in_python

Image
                   what is strings?? In python, anything that you enclose between single or double quotation marks is considered a string. A string is essentially a sequence or array of textual data. strings are used when working with unicode characters. ex. input- name="hardik" print("hello, "+name) output-  hello,hardk name="hello world" #sequence of the characters print(name[0]) print(name[1]) print(name[2]) print(name[3]) print(name[4]) output- h e e l o case changing of python 1. lower():   convert all uppercase characters in a string into lowercase. 2.upper(): converts all lowercase characters in a string into uppercase. 3.title(): convert string to title case 4.swapcase(): swap the cases of the characters in a string 5.capitalize(): convert the first characters of a string to uppercase      input- output- List of string methods in python 6.casefold(): implements caseless string method 7.center(): pad the...

day #8 Taking_User_input_in_python

Image
                                   User - Input # In python, we can take user input directly by using  input()  function. this input function gives a return value as string/character hence we have to pass that into a variables. ex. input- a=input("enter your name: ") print("my name is", a) output- enter your name: harry my name is harry # look at this program - x=input("enter your first number : ") y=input("enter your second number: ") print(x+y) print(int(x)+int(y)) output- enter your first number : 56 enter your second number: 56   # first answer : 5656 # second answer: 112 # you are expect this program answer is 112 but its not write the real value of 5656 # reason of your computer doesn't  understood value or integer value . # than if we calculate of two, three or many number than i will program-  int(integer) x=int(input("enter your first number: ")) y=int(input("enter...

day #7 - typecasting__in__Python

Image
                         Type-Casting 'The  Conversion of one data type into the other data type is known as type casting in python or type  conversion in python." python supports a wide variety of functions or methods like: int(), float(), str(), ord(), tuple(), set(), list(), hex(), oct(), duct(), etc. type-casting in python  Example input- a="2" b="3" print(a+b) Output- 23 #You might be expecting that the answer will be 5. # But the answer will be 23 because the computer is considering the variables A and B as strings . Two types of type-casting- 1.  Explicit Conversion  ( means I'm doing ) The conversion of one data type into another data type, done via developer or programmer's intervention or manually as per the requirement, is knows as explicit type conversion. ex. intput-           string="67"          number = 7       ...

day #6 - Exercise 1: make two Calculator using in python

Image
  I have two calculator programs code : You can easily use it on computer and mobile:- Our 1st.Question- - Create a calculator capable of performing addition , subtraction, multiplication and division operations  on two numbers. Our program code -- Input- a = int(input("enter your first number:")) b=int(input("enter your second number:")) print(a+b) print(a-b) print(a*b) print(a/b) Output- enter your first number:5 enter your second number:5 10 0 25 1.0 Our 2nd Question.: how to make best & advance calculator to include anything.? Our program code : def add(x, y):     return x + y def subtract(x, y):     return x - y def multiply(x, y):     return x * y def divide(x, y):     if y == 0:         return "Error! Division by zero!"     else:         return x / y print("Select operation:") print("1. Add") print("2. Subtract") print("3. Multiply") print("4. Divide") while True:    ...

day #5 - Operators in python

Image
     ' OPERATORS' - So,   'Operators are simple we already have studied this in mathematics' " python have different types of  operators for different operators, to create a calculators we required arithmetic operators." 1. Arithmetic operators- 2. Relational Operators- 3. Assignment Operators- 4. Logical Operators- 5. Bitwise Operator- 6. Membership Operators-                                               or 7. Identity Operators-       

Day #4 - variables and Data Types

Image
                    Variables -- variables are like containers just like you have in your kitchen  in which you store lentils , flour & rice etc.  in python programming language 'variables' are just like those containers. that you people make containers and store data in them. and this data is stored in the memory.it is stored in it, what you call 'RAM'   Program-- what is data types-- " data type specifies the types of value a variables holds. this is required in programming to do various operations without causing an error. just like a container can contain 'Liquid' 'Solid' 'Lentils' or 'Sugar' just like that there are 'type' in python which we refer as 'data types' output-      1. Numeric data: int,  float, complex int:  7, -5 ,0 float: 7.345, -5.0, 0.00001 complex: 6+2i 2 . text data: str    str: "hello world!", "python programming" 3. Boolean data:    Boolean data ...