Skip to content

Commit 5b4e84d

Browse files
committed
lab 17-01-23
1 parent d1bbe93 commit 5b4e84d

File tree

5 files changed

+32
-1
lines changed

5 files changed

+32
-1
lines changed

Lab/String/PrintString2.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# In this program we will see how to print string from a lenth to a destination lenth
2-
"""asume name is a string where name[start:end:difference]"""
2+
#name[start:end:difference]
33
name = "Rajesh Bhadra"
44
# Printing from 7 to the end of the string
55
print(name[7:])

Questions/AddIs.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Write a Python program to get a new string from a given string where "Is" has been added to the front. If the given string already begins with "Is" then return the string unchanged.
2+
sValue = input("Enter a word ")
3+
if sValue[0:2:] == "is" :
4+
print(sValue)
5+
else:
6+
print("is "+sValue)
7+

Questions/CalculateThreeNumber.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Write a Python program to calculate the sum of three given numbers, if the values are equal then return three times of their sum.
2+
val1 = int(input("Enter value 1: "));
3+
val2 = int(input("Enter value 2: "));
4+
val3 = int(input("Enter value 3: "));
5+
6+
if val1 == val2 & val2 == val3:
7+
print(3*(val1+val2+val3))
8+
else:
9+
print(val1+val2+val3)

Questions/CopiesString.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Write a Python program to get a string which is n (non-negative integer) copies of a given string.
2+
value = input("Enter your string: ")
3+
vRange = int(input("Enter range: "))
4+
5+
if vRange >0:
6+
for i in range(0,vRange):
7+
print(value+ " ")
8+
else:
9+
print("Please enter non negetiv value ")

Questions/DifferenceBtnGiven.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# 9.Write a Python program to get the difference between a given number and 17, if the number is greater than 17 return double the absolute difference.
2+
value = int(input("Enter number: "))
3+
if value > 17:
4+
print((17-value)*(17-value))
5+
else:
6+
print((17-value))

0 commit comments

Comments
 (0)