Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
pythonfin
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
#python 3.5.2 #pgm1 '''string1=input("enter string1:") string2=input("enter string2:") string3="" for i in range(len(string1)): if(string1[i].isupper()): string3+=string1[i] for i in range(len(string2)): if(string2[i].isupper()): string3+=string2[i] print("merged string is:",string3) ''' #pgm2 '''l=[] for i in range(2000,3201): if(i%7 == 0 and i%5 != 0): l.append(i) a=','.join(map(str,l)) print(a)''' #pgm3 '''s=input("enter the numbers") b=s.split(',') print(b) a=tuple(b) print(a)''' #pgm4 '''s=input("enter the words:") a=s.split(',') a.sort() b=','.join(a) print("the output is:") print(b)''' #pgm5 '''d=0 for i in range(2010,2021): if(i%400==0 or (i%100!=0 and i%4==0)): d+=366 else: d+=365 print("number of days:",d) ''' #pgm6 '''name=input("enter name:") h=int(input("enter the hours worked in a week:")) p=float(input("enter the pay rate:")) w=int(input("enter number of weeks in a month")) m=h*p*w print("employee name:",name) print("monthly pay:",m)''' #pgm7 '''empid=input("enter employee id:") basal=float(input("enter basic salary:")) alo=float(input("enter allowances:")) gross=basal+alo if(gross>20000): inct=0.3*gross elif(gross>=10001 and gross <=20000): inct=0.2*gross elif(gross>=5001 and gross <=10000): inct=0.1*gross else: inct=0 net=gross-inct print("employee id:",empid) print("basic salaray: Rs ",basal) print("allowances: Rs ",alo) print("gross salary: Rs ",gross) print("income tax: Rs ",inct) print("net pay: Rs ",net)''' #pgm8 '''flag=0 while flag==0: bid=int(input("enter bill id:")) cid=int(input("enter cust id:")) camt=float(input("enter customer amount:")) cname=input("enter customer name:") if(len(cname)>=3 and len(cname)<=20): print("bill id:",bid) print("cust id:",cid) print("cust amount:",camt) print("cust name:",cname) flag=1 ''' #pgm9 '''st=input("enter a string:") a=st[::-1] if(a==st): print("%s is a palindrome"%(st)) else: print("%s is not a palindrome"%(st))''' #pgm10 '''f1=0 f2=1 n=int(input("enter the value of n:")) if(n==0): print("not possible") elif(n==1): print(f1,end=' ') else: print(f1,end=' ') print(f2,end=' ') for i in range(2,n): f3=f1+f2 print(f3,end=' ') f1=f2 f2=f3''' #pgm11 '''count=0 st=input("enter a string") for i in range(len(st)): if(st[i].isupper()): count+=1 print("the number of capital letters in %s is %d"%(st,count)) ''' #pgm12 '''s=input("enter a string:") vow=['a','e','i','o','u','A','E','I','O','U'] count=[0]*len(vow) for i in s: if i in vow: count[vow.index(i)]+=1 print("occurances") for i in range(len(vow)): print(vow[i]+"=",count[i])''' #pgm13 '''s=input("enter a string") u="" for i in range(len(s)): if(s[i] not in "’!()-[]{};:’’’,\,<>,/,?,@,#,$,%^&*_~"): u+=s[i] print("the final string is:",u)''' #pgm14 '''l=[2,4,1,6,7,9,2] n=len(l) srt=l.sort() key=int(input("enter key element:")) lw=0 h=n-1 flag=0 while lw<=h: mid=int((lw+h)/2) if(l[mid]==key): flag=1 break elif(l[mid]>=key): h=mid-1 else: lw=mid+1 if(flag==1): print("%d found at position %d"%(key,(mid))) else: print("%d not found"%(key))''' #pgm14(11) '''l=[] n=int(input("enter number of elements:")) print("enter elements") for i in range(n): s=int(input()) l.append(s) srt=l.sort() key=int(input("enter key element:")) lw=0 h=n-1 flag=0 while lw<=h: mid=int((lw+h)/2) if(l[mid]==key): flag=1 break elif(l[mid]>=key): h=mid-1 else: lw=mid+1 if(flag==1): print("%d found at position %d"%(key,(mid))) else: print("%d not found"%(key))''' #bubble sort '''l=[] n=int(input("enter the number of elements")) for i in range(n): s=int(input()) l.append(s) for i in range(n-1): for j in range(n-i-1): if(l[i]>l[i+1]): temp=l[i] l[i]=l[i+1] l[i+1]=temp print("the bubble sorted :") print(l)''' #sum of digits and occurance of digit '''n=int(input("enter the number:")) d=int(input("enter the digit:")) temp=n count=0 sum=0 while n!=0: rem=int(n%10) sum+=rem n=n/10 if(rem==d): count+=1 print("sum:",sum) print("occurance of %d in %d is %d"%(d,temp,count))''' #armstrong number '''n=int(input("enter the number")) temp=n temp2=n count2=0 rem2=0 rem=0 sum=0 while temp2!=0: count2+=1 rem2=(temp2%10) temp2=temp2/10 while temp!=0: rem=(temp%10) sum=sum+(rem**count2) temp=temp/10 if(sum!=n): print("%d is not armstrong number"%(n)) else: print("%d is an armstrong number"%(n)) ''' #reverse a number and check if it is palindrome or not '''n=(input("enter a number")) t=n[::-1] if(t==n): n=int(n) print("%sis a palindrome"%(n)) else: print("given number is not a palindrome")''' #sum of list and its average '''l=[] n=int(input()) for i in range(n): k=int(input()) l.append(k) a=sum(l) avg=a/len(l) print("sum=",a) print("avg=",avg)''' #gcd and lcm '''a=int(input("enter the first numbers:")) b=int(input("enter the second numbers:")) t1,t2=a,b rem=0 while b!=0: rem=a%b a=b b=rem gcd=a lcm=int((t1*t2)/gcd) print("gcd=",gcd) print("lcm=",lcm)''' #largest of 4 numbers '''l=[] for i in range(4): s=int(input()) l.append(s) maxi=max(l) print("largest number is:",maxi)''' #square root of a number '''import math m=int(input("enter number")) sq=m**0.5 n=int(input("enter number")) sq2=math.sqrt(n) o=int(input("enter number")) sq3=math.pow(o,0.5) print("sqare root1:",sq) print("sqare root1:",sq2) print("sqare root1:",sq3)''' #file '''f1=open("file.txt","w") n=int(input("enter the number")) for i in range(n): usn=input() name=input() f1.write(usn+" "+name+"\n") f1.close()'''
386,982,413,0928
[
-
]
Show input
edit mode
|
history
|
discussion