GoConqr hat ein neues Design! Sag uns, wie es dir gefällt.

Notizen

python

sneha singh Englisch 1 Seite

Inhalt der Notizen (1)

Seite 1

"""

#1)reverse a number and check if it is palindrome

print("enter a number")

num=int(input())

num1=num

rev=0

while(num>0):

rem=num%10

rev=rev*10+rem

num=num//10

print(rev)

if(num1==rev):

print("palindrome")

else:

print("not palindrome")

"""

"""

#2)fibonaci series

print("enter number of terms to print")

num=int(input())

b,c=0,1

print(b)

while(num-2):

d=b+c

b=c

c=d

print(c)

num=num-1

"""

"""

#3)print numbers which are not divisible by 2 or 3

for i in range (1,25):

if((i%2!=0)&(i%3!=0)):

print(i)

"""

"""

#4)sum of digits of number

print("enter a number")

num=int(input())

sum=0

while(num>0):

num1=num%10

sum=sum+num1

num=num//10

print(sum)

"""

"""

#5)

def newfunc():

print("hello")

newfunc()

newfunc()

"""

"""

#

def newfunc():

print("enter numbers to multiply")

num1=int(input())

num2=int(input())

mul=num1*num2

print("multiplication: " + str(mul))

newfunc()

"""

"""

def func1(a,b):

mul=a*b

return mul

print("enter a and b")

a=int(input())

b=int(input())

z=func1(a,b)

print(z)

"""

"""

def func1(a,b):

mul=a*b

return mul

print("enter a and b")

a=int(input())

b=int(input())

z=func1(a,b)

print(z)

a=2

b=3

z=func1(a,b)

print(z)

"""

"""

def reverse():

print("enter a number")

num=int(input())

num1=num

rev=0

while(num>0):

rem=num%10

rev=rev*10+rem

num=num//10

print(rev)

reverse()

"""

"""

import sys

print("initial balance is")

balance=500

print(balance)

def deposite():

sum=balance+dep

return sum

def withdraw():

sum=balance-wit

return sum

while(1):

print("enter 1)deposite \t 2) withdraw \t 3)exit")

ch=int(input())

if(ch==1):

print("enter balance to deposite:")

dep=int(input())

balance=deposite()

print("Balance is :" + str(balance))

elif(ch==2):

print("enter balance to withdraw:")

wit=int(input())

balance=withdraw()

print("Balance is :" + str(balance))

elif(ch==3):

print( "Final Balance is :" + str(balance))

sys.exit()

"""

"""

def func(a=10,b=23)

print(a,b)

"""

"""

def total(initial=5,*numbers,**keywords):

count=initial

for num in numbers:

count+=num

for key, value in keywords.items():

print(key,value)

for key in keywords:

count+=keywords[key]

return count

print(total(10,1,2,3,vegetables=50,fruits=100))

"""

"""

name = input("what is your name")

print("name",name)

"""

"""

l=[2,{},"lalit"]

print(l)

"""

"""

l=list('spam')

print(l)

print(l[0])

"""

"""

l1=("cat", "bat", "rat")

print(l1[1])

"""

"""

s='lalitanmns'

print(s[1:7:2])

"""

"""

print('lalit' in ['lalit', 'sandeep'])

"""

"""

r=[c*4 for c in 'spam']

print(r)

"""

"""

l=[2,3,4,5,'all']

l.append(5)

print(l)

"""

"""

l1=[1,2,3,4]

l2=[2,8]

l1.extend(l2)

print(l1)

"""

"""

l1=[1,2,3,4]

l1.insert(0,9)

print(l1)

"""

"""

l1=[1,2,3,4]

l1.remove(2)

print(l1)

"""

"""

l1=[1,2,3,4]

print(l1.pop(0))

"""

"""

l1=[1,2,2,3,4]

print(l1.count(2))

"""

"""

l1=[1,6,8,2,3,4]

l1.sort()

print(l1)

"""

"""

import copy

l1=[1,2,3,4]

l2= copy.copy[l1]

print(l2)

"""

"""

l1=(1,6,8,2,3,4)

print(l1)

"""

"""

(x,y)=(1,2)

print(x,y)

"""

"""

#push and pop

import sys

def push():

print("enter the element to insert")

x=int(input())

l1.append(x)

print(l1)

return l1

def pop():

print("enter the element to remove")

y=int(input())

l1.pop(y)

print(l1)

return l1

def main():

while(1):

print("enter your choice 1) push 2)pop 3)exit")

a=int(input())

if(a==1):

push()

elif(a==2):

pop()

elif(a==3):

sys.exit()

l1=[1,2,3,4]

if __name__ == "__main__":

main()

print(l1)

"""

"""

l1=[1,3,6,78,35,55]

l2=[12,24,35,24,88,120,155]

for i in l1:

for ii in l2:

if(i==ii):

print(i)

"""

"""

l1=[1,3,6,78,35,55]

l2=[12,24,35,24,88,120,155]

for i in l1:

if i in l2:

print(i)

"""

"""

head=35

legs=94

x=legs%head

y=x//2

chick=head-y

print(chick)

rabbit=head-chick

print(rabbit)

"""

"""

head=35

legs=94

x=legs//2

y=x-head

chick=head-y

print(chick)

rabbit=head-chick

print(rabbit)

"""

"""

l1=[12,24,35,24,88,120,155,88,120,155]

for i in l1:

if i not in l1:

print(i)

"""

"""

d1={'size':'fat','colour':'white','disposition':'loud'}

d2={'size':'fat','disposition':'loud','colour':'white'}

d1==d2

"""

"""

#SETS

l1=[1,3,6,78,35,55]

l2=[12,24,35,24,88,120,155]

set1=set(l1)

set2=set(l2)

l3=set1 & set2

print(l3)

"""

"""

l1=[2,4,6,8]

for i in l1:

assert i%2==0

print("even")

"""

"""

for line in f:

print(line,end=)

"""

"""

file=open("data2.txt","w")

file.write("write this ")

file.close()

"""

"""

file=open("data2.txt","r")

print(file.read())

file.close()

"""

"""

f=open('data2.txt')

text=f.read()

print(text)

f=open("data2.txt","a")

f.write("add this")

f.close()

"""

"""

sub=['i', 'you']

verb= ['play', 'love']

obj= ['hockey', 'football']

for i in sub:

for j in verb:

for k in obj:

print(i +j +k)

"""

"""

#to remove even number from list

l1=[5,6,77,45,22,12,24]

l2=[]

for i in l1:

if(i%2!=0):

l2.append(i)

print(l2)

"""

"""

l1=[5,6,77,45,22,12,24]

l1=[x for x in l1 if x%2!=0]

print(l1)

"""

"""

r= lambda x,y:x*y

print(r(2,4))

"""

"""

import sys

import push1

def main():

while(1):

print("enter your choice 1) push 2)pop 3)exit")

a=int(input())

if(a==1):

push1.push()

elif(a==2):

push1.pop()

elif(a==3):

sys.exit()

if __name__ == "__main__":

main()

print(l1)

"""

"""

import random

import sys

y=random.randint(1,9)

while(1):

print("guess a number between 1 to 9\n")

x=int(input())

if(x>y):

print("number is high\n")

elif(x<y):

print("number is low\n")

elif(x==y):

print("bang on\n")

sys.exit()

"""

"""

l1=[]

l2=[]

while(1):

print("1 or 2")

y=int(input())

if(y==1):

print("enter the element to insert")

x=int(input())

l1.append(x)

print(l1)

elif(y==2):

l2=l1.pop(x)

print(l2)

elif(y==3):

sys.exit()

"""

"""

print("enter a number to check prime ")

a=int(input())

if(a>=1):

for i in range (2,(a-1)):

if(a%i==0):

print("not prime")

break

else:

print("prime")

if(a==1):

print("not prime")

"""

"""

m1=[[2,3],[9,8]]

m2=[[6,5],[4,2]]

m3=[[0,0],[0,0]]

for i in range (len(m1)):

for j in range (len(m2)):

m3[i][j] +=m1[i][j]+m2[i][j]

print(m3)

"""

"""

print("enter number")

n=int(input())

for i in range(0,n+1):

for j in range (1,i+1):

print(i,end="")

print("\r")

"""

"""

import random

import sys

y=random.randint(1,9)

while(1):

print("guess a number between 1 to 9\n")

x=int(input())

if(x>y):

print("number is high\n")

elif(x<y):

print("number is low\n")

elif(x==y):

print("bang on\n")

sys.exit()

"""

"""

import random

qw=1

name=['cheery','orange','tomato','banana']

x=random.randint(0,3)

y=name[x]

z=[]

print(y) #to check

for i in range(len(y)):

z.append("_")

print(z)

while(qw<10):

#print("x"+ str(qw))

print("enter a character")

ch=input()

for i in range(len(y)):

if(ch==y[i]):

z[i]=y[i]

print(z)

print("x"+ str(qw))

qw=qw+1

""""

"""

import random

fruitname = ['apple', 'orange', 'mango', 'peach', 'guava']

wordsToGuess = ""

activeGuess = list()

guesses = list()

lives = 7

a=input("enter any l fruitnmae")

wordsToGuess = random.choice(fruitname)

for i in range(len(wordsToGuess)):

activeGuess.append("_")

while lives > 0 and ("_" in activeGuess):

print("You have", lives, "guesses")

print(activeGuess)

guess = input("Please enter your guess: ")

while guess in guesses:

print("invalid input")

guess = input("Please enter your guess: ")

guesses.append(guess)

if(guess in wordsToGuess):

for i in range(len(wordsToGuess)):

if(guess == wordsToGuess[i]):

activeGuess[i] = guess

else:

lives -=1

if lives > 0 and lives <7:

print("CONGRATULATIONS! YOU WON!\n" , activeGuess)

print(activeGuess)

elif lives == 7:

print("*PERFECT VICTORY*\n" , activeGuess)

print(activeGuess)

else:

print("Good Try, Try Again!\n" , activeGuess)

"""

Informationen

Beschreibung
Notiz am python, erstellt von sneha singh am 25/04/2019.
Erstellt von
sneha singh
Aufrufe
1
Bewertung

Feedback

Worum geht es?

Wie gefällt dir das neue Design?

Dein Eindruck