0% found this document useful (0 votes)
21 views

Input

The document contains code snippets for several Python programs that: 1) Accept a number as input and check if it is a "buzz number" based on divisibility by 7 or ending in 7. 2) Accept a number as input and check if it is a "pronic number" which is a number that is the product of consecutive integers. 3) Calculate a taxi fare based on distance traveled and a fixed amount for the first 10 km. 4) Accept a number as input, reverse it, and print the reversed number. 5) Find the highest common factor of two numbers.

Uploaded by

S.Sreerevanth
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Input

The document contains code snippets for several Python programs that: 1) Accept a number as input and check if it is a "buzz number" based on divisibility by 7 or ending in 7. 2) Accept a number as input and check if it is a "pronic number" which is a number that is the product of consecutive integers. 3) Calculate a taxi fare based on distance traveled and a fixed amount for the first 10 km. 4) Accept a number as input, reverse it, and print the reversed number. 5) Find the highest common factor of two numbers.

Uploaded by

S.Sreerevanth
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

write a program to accept a number and check whether it's a buzz

number in python

n=int(input('Enter a number '))

if n%7==0 or n%10==7:

print('Buzz number')

else:

print('Not a buzz number')

write a program to input a number check and print whether it is a


pronic number

n= int(input("enter the number "))

f =0

for i in range(n):

if i*(i+1)==n:

f =1

break

if f==1:

print("pronic")

else
print("not pronic")

x=int(input("enter the km"))

fa=int(input("enter the fixed amount(first 10 km)"))

ak=x-10

if(x<=10):

print(fa)

else:

am=ak*20

ta=am+fa

print(ta)

num = int(input("enter any digit num"))

reversednum = 0

while num != 0:

digit = num % 10
print(digit)

reversednum = reversednum * 10 + digit

num //= 10

print("Reversed Number: " ,reversednum)

a=int(input("Enter the first number:"))

b=int(input("Enter the second number:"))

if(a>b):

max=a

else:

max=b

for i in range (max,1+(a*b)):

if(i%a==i%b==0):

break

print(i)
num1 = int(input("enter the number"))

num2 = int(input("enter the number"))

a = num1

b = num2

while num1 != num2:

if num1 > num2:

num1 -= num2

else:

num2 -= num1

print("Hcf of", a, "and", b, "is", num1)

prime numbers

Method Description

capitalize() Converts the first character to upper case

casefold() Converts string into lower case


center() Returns a centered string

count() Returns the number of times a specified value occurs in a string

encode() Returns an encoded version of the string

endswith() Returns true if the string ends with the specified value

expandtabs() Sets the tab size of the string

find() Searches the string for a specified value and returns the position of where

format() Formats specified values in a string

format_map() Formats specified values in a string

index() Searches the string for a specified value and returns the position of where

isalnum() Returns True if all characters in the string are alphanumeric

isalpha() Returns True if all characters in the string are in the alphabet
isascii() Returns True if all characters in the string are ascii characters

isdecimal() Returns True if all characters in the string are decimals

isdigit() Returns True if all characters in the string are digits

isidentifier() Returns True if the string is an identifier

islower() Returns True if all characters in the string are lower case

isnumeric() Returns True if all characters in the string are numeric

isprintable() Returns True if all characters in the string are printable

isspace() Returns True if all characters in the string are whitespaces

istitle() Returns True if the string follows the rules of a title

isupper() Returns True if all characters in the string are upper case

join() Converts the elements of an iterable into a string


ljust() Returns a left justified version of the string

lower() Converts a string into lower case

lstrip() Returns a left trim version of the string

maketrans() Returns a translation table to be used in translations

partition() Returns a tuple where the string is parted into three parts

replace() Returns a string where a specified value is replaced with a specified value

rfind() Searches the string for a specified value and returns the last position of wh

rindex() Searches the string for a specified value and returns the last position of wh

rjust() Returns a right justified version of the string

rpartition() Returns a tuple where the string is parted into three parts

rsplit() Splits the string at the specified separator, and returns a list
rstrip() Returns a right trim version of the string

split() Splits the string at the specified separator, and returns a list

splitlines() Splits the string at line breaks and returns a list

startswith() Returns true if the string starts with the specified value

strip() Returns a trimmed version of the string

swapcase() Swaps cases, lower case becomes upper case and vice versa

title() Converts the first character of each word to upper case

translate() Returns a translated string

upper() Converts a string into upper case

zfill() Fills the string with a specified number of 0 values at the beginning

You might also like