Commit 2062cc24 authored by rachana miryala's avatar rachana miryala
Browse files

Upload New File

parent b64a120e
Pipeline #21492 passed with stage
in 13 seconds
%% Cell type:code id: tags:
``` python
#task-1
n=int(input('enter a num'))
if n>21:
print(2*(n-21))
else:
print(n-21)
```
%% Output
enter a num23
4
%% Cell type:code id: tags:
``` python
#task-3
f='venkat'
#l=len(a)
b=int(input('enter a num'))
#a=a[0:b-1]+a[b:l]
f=f.replace(f[b],"")
print(f)
f[b]
```
%% Output
enter a num3
venat
'a'
%% Cell type:code id: tags:
``` python
#task-4
x=int(input('enter number'))
y=int(input('enter number'))
if x==y:
print((x+y)**2)
else:
print(x+y)
```
%% Output
enter number3
enter number2
5
%% Cell type:code id: tags:
``` python
#task-2
k=int(input('enter num'))
if (abs(100-k) or abs(200-k))<=10:
print('true')
else:
print('false')
```
%% Output
enter num90
true
%% Cell type:code id: tags:
``` python
#task-5
g=input('enter a string')
h=int(input('enter a number'))
print(h*g)
```
%% Output
enter a stringrachana
enter a number3
rachanarachanarachana
%% Cell type:code id: tags:
``` python
#task-6
r=[1,2,3,4,5,6]
even=[]
odd=[]
for i in r:
if i%2==0:
even.append(i)
else:
odd.append(i)
print('numbers of even numbers=',str(len(even)))
print('even list=',even)
print('number of odd numbers=',str(len(odd)))
print('odd list',odd)
```
%% Output
numbers of even numbers= 3
even list= [2, 4, 6]
number of odd numbers= 3
odd list [1, 3, 5]
%% Cell type:code id: tags:
``` python
#task-7
e=input('enter some comma separated elements')
list=e.split(",")
tuple=tuple(list)
print('tuple=',tuple)
print('list=',list)
```
%% Output
enter some comma separated elements2,3,4,5,6,7,8
tuple= ('2', '3', '4', '5', '6', '7', '8')
list= ['2', '3', '4', '5', '6', '7', '8']
%% Cell type:code id: tags:
``` python
#task-8
h=[]
evenn=[]
oddd=[]
n=int(input('enter a number'))
for j in range(0,n):
elements=int(input('enter element'))
if j%2==0:
evenn.append(elements)
else:
oddd.append(elements)
#print('numbers of even numbers=',str(len(evenn)))
print('even list=',evenn)
#print('number of odd numbers=',str(len(oddd)))
print('odd list',oddd)
```
%% Output
enter a number7
enter element1
enter element2
enter element3
enter element4
enter element5
enter element6
enter element7
even list= [1, 3, 5, 7]
odd list [2, 4, 6]
%% Cell type:code id: tags:
``` python
#task-9
from datetime import datetime
datetime.now().strftime('%Y-%m-%d %H:%M:%S')
```
%% Output
'2019-05-31 14:28:05'
%% Cell type:code id: tags:
``` python
#task-10
j=int(input('enter'))
k=int(input('enter'))
if j==10 or k==10 or j+k==10:
print('true')
else:
print('false')
```
%% Output
enter3
enter7
true
%% Cell type:code id: tags:
``` python
a=[]
n=int(input("Enter number of elements:"))
for i in range(1,n+1):
b=int(input("Enter element:"))
a.append(i)
even=[]
odd=[]
for j in a:
if(j%2==0):
even.append(j)
else:
odd.append(j)
print("The even list",even)
print("The odd list",odd)
```
%% Output
Enter number of elements:6
Enter element:1,7,3,9,4,2
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-58-cf67c362ffcd> in <module>
2 n=int(input("Enter number of elements:"))
3 for i in range(1,n+1):
----> 4 b=int(input("Enter element:"))
5 a.append(i)
6 even=[]
ValueError: invalid literal for int() with base 10: '1,7,3,9,4,2'
%% Cell type:code id: tags:
``` python
```
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment